Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of improvements #18

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
59a0a5e
More Uni groups
longngo78 Jun 24, 2015
6561755
UniGroupItemRenderer
longngo78 Jun 24, 2015
e130852
minor changes
longngo78 Jun 24, 2015
b2569ab
swipe stuff
longngo78 Jun 26, 2015
c766403
AtlasFrame supports flipping vertical and horizontal
longngo78 Jul 3, 2015
73f14df
fixed crash when setTexture() after having children
longngo78 Jul 8, 2015
148c735
minor changes
longngo78 Jul 9, 2015
e7e4b65
minor changes
longngo78 Jul 12, 2015
34682df
minor features
longngo78 Jul 16, 2015
5aa7854
added getLastDelta()
longngo78 Jul 17, 2015
3f773c3
added APIs to get sub-frame sets
longngo78 Jul 21, 2015
e299081
fixed setPivotAtCenter()
longngo78 Jul 23, 2015
a2ffe83
fixed NPE
longngo78 Jul 23, 2015
1394f49
MotionTraceShape to trace precisely motion
longngo78 Jul 23, 2015
0fffa48
fixed minor bug
longngo78 Jul 24, 2015
b7265df
detect circle intersects rectangle
longngo78 Jul 24, 2015
7e9c48d
support FPS for sub frame set
longngo78 Jul 25, 2015
76f994c
setLetterSpacing()
longngo78 Jul 28, 2015
227893b
Font with better stroke
longngo78 Jul 29, 2015
21eb6ee
setData for invisible items
longngo78 Jul 30, 2015
f51a4ea
added TweenAnimatorListener
longngo78 Aug 5, 2015
96dc95d
Support both Frame Index and Name for SubFrameSet.
longngo78 Aug 5, 2015
f390634
Clip supports setLoopCount()
longngo78 Aug 12, 2015
52502e0
fixed crash
longngo78 Aug 13, 2015
33f25b2
added flipX and flipY to Button
longngo78 Aug 14, 2015
fca47e3
Line intersects Rectangle
longngo78 Aug 20, 2015
2b94db1
refactor to unify DisplayObject and UniObject
longngo78 Aug 20, 2015
3936c06
added Listener
longngo78 Aug 25, 2015
215c9ed
keep origin if already set
longngo78 Aug 25, 2015
37785a2
fixed double data setting issue on Data Lists
longngo78 Aug 27, 2015
6f93508
fixed origin at center
longngo78 Aug 29, 2015
4db1557
onBroughtUp() onBroughtDown()
longngo78 Sep 3, 2015
2f0ae87
PageStacker.onResume()
longngo78 Sep 3, 2015
29ec7d6
fixed origin at center issue for Clips
longngo78 Sep 4, 2015
281e195
getCurrentFps()
longngo78 Sep 4, 2015
cda7117
removed final
longngo78 Sep 16, 2015
aa095b5
IOException
longngo78 Sep 19, 2015
fb45c3b
allocateBuffers(), unallocateBuffers()
longngo78 Sep 19, 2015
a831656
quick fix for clipping
longngo78 Sep 20, 2015
6d2000f
repeating texture
longngo78 Sep 21, 2015
32d42f6
auto set Texture Repeat when necessary
longngo78 Sep 21, 2015
22f9258
more features for Clip and LinearGroup
longngo78 Oct 1, 2015
e1443df
changed invalidate flag from CHILDREN to VERTICES
longngo78 Oct 9, 2015
fb1d301
diff check before calling setNumDrawingChildren()
longngo78 Oct 9, 2015
1bda28f
diff check before flag POSITION
longngo78 Oct 9, 2015
c54c013
do NOT use CHILDREN flag for repositioning children
longngo78 Oct 9, 2015
051ef7a
do NOT use CHILDREN flag
longngo78 Oct 9, 2015
459e095
optimized setPosition()
longngo78 Oct 9, 2015
d4a78f4
minor
longngo78 Oct 10, 2015
eab2600
fixed text bounds issue
longngo78 Oct 10, 2015
2303a55
reformatted
longngo78 Oct 10, 2015
af56cfe
fixed wrapping issue when content shrinks
longngo78 Oct 11, 2015
e600859
onAnimationLoop
longngo78 Oct 14, 2015
84dfd1d
UniObject.updateChildren()
longngo78 Oct 14, 2015
07eea03
PageStacker.findPreviousPageOf()
longngo78 Oct 16, 2015
a91ec55
complete BmfText
longngo78 Oct 17, 2015
38d5963
SoundManager.unloadAll()
longngo78 Oct 18, 2015
e55b9e5
refactored privatePlay()
longngo78 Oct 18, 2015
ed2c062
setRate() getRate()
longngo78 Oct 19, 2015
df907a4
fixed NPE
longngo78 Dec 2, 2015
eb1e550
fixed accumulating
longngo78 Dec 5, 2015
00a91bd
Revert "fixed accumulating"
longngo78 Dec 5, 2015
bae598f
Revert "Revert "fixed accumulating""
longngo78 Dec 5, 2015
224c0c7
Revert "fixed NPE"
longngo78 Dec 5, 2015
ac9c217
fixed NPE
longngo78 Dec 5, 2015
9507dad
fixed stupid chars
longngo78 Dec 5, 2015
fb3cdac
attempt fix NPE for HVGroups
longngo78 Dec 14, 2015
72298dc
Button fix
longngo78 Dec 14, 2015
8606aaa
UIManager calls preloadAssets()
longngo78 Dec 14, 2015
0b3b492
UniDataGrid
longngo78 Dec 15, 2015
e44683a
Sprite9 setAlive
longngo78 Dec 18, 2015
ad12913
optimized Sprite9
longngo78 Dec 18, 2015
b69082e
fixed getFrame()
longngo78 Dec 18, 2015
fa9c81f
PageStacker returns true onBackPress()
longngo78 Mar 15, 2016
830d50b
minor
longngo78 Apr 6, 2016
72197c0
BlendModes.DEFAULT_FUNC
longngo78 Apr 7, 2016
ff45e1f
com.android.tools.build:gradle:2.0.0
longngo78 Apr 9, 2016
e2865ca
fixed Button
longngo78 Apr 12, 2016
297a610
Scene clean up and color animation
longngo78 Apr 15, 2016
dd73674
Updated to gradle:2.2.0, buildToolsVersion "23.0.2"
longngo78 Dec 31, 2016
70e5c2b
replaced copyrighted assets
longngo78 Dec 31, 2016
206465b
manager.evalString(color)
longngo78 Mar 8, 2017
fbb0f46
Merge branch 'master' of https://github.com/longngo78/pure2d
longngo78 Mar 8, 2017
30644dd
gradle:2.2.3
longngo78 Mar 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Pure2D Native Android Game Engine

Pure2D is a free and open source Game Engine for Android.
It's designed for Android OS and built on top of OpenGL-ES v1.x.
Pure2D provides a powerful API set and amazing performance.

## Homepage:
http://gree.github.io/pure2d/

## Github:
https://github.com/gree/pure2d

## Demo Source:
https://github.com/gree/pure2d/tree/open-master/pure2D-demo

## Demo APK:
https://play.google.com/store/apps/details?id=com.longo.pure2D.demo

## Features:
```
Native Android and OpenGL-ES v1.x
Built-in Particle System
Built-in UI & Layout System, with multi-touch supported
Build-in Grid System, simple A* pathfinding
LWF Plugin
Backgrounded and asynchronous Asset Loading framework
Batch Drawing supported
Bitmap fonts, text rendering supported
TexturePacker's Sprite Sheet and JSON format supported
Box2D Physics Engine Plugin
Huge library for Tween Animations
Familiar APIs, mimics the conventional Flash architecture
Amazing performance, 60 fps for most graphics intensive games
```
## Documentation:
http://gree.github.io/pure2d/doc

```
Please let us know if you'd like to contribute.
Thank you for visiting!
```
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:2.2.3'
}
}

Expand Down
2 changes: 1 addition & 1 deletion pure2D/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 8
Expand Down
1 change: 0 additions & 1 deletion pure2D/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
</application>

Expand Down
104 changes: 70 additions & 34 deletions pure2D/src/main/java/com/funzio/pure2D/BaseDisplayObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ protected void drawBounds(final GLState glState) {

@Override
public boolean update(final int deltaTime) {
// check constraints first ,only apply it when size or parent changed
// check constraints first, only apply it when size or parent changed
if (mUIConstraint != null && (mInvalidateFlags & (SIZE | PARENT | PARENT_BOUNDS)) != 0) {
mUIConstraint.apply(this, mParent);
mUIConstraint.apply(this, getParent());
}

// update the manipulators if there's any
Expand Down Expand Up @@ -366,12 +366,14 @@ protected void updateChildren(final int deltaTime) {
/**
* @hide
*/
@Deprecated
final public void invalidate() {
// invalidate generally, NOT!
// mInvalidateFlags = ALL;

if (mParent != null) {
mParent.invalidate(CHILDREN);
final Parentable parent = getParent();
if (parent != null) {
parent.invalidate(CHILDREN);
}
}

Expand All @@ -381,8 +383,9 @@ final public void invalidate() {
public void invalidate(final int flags) {
mInvalidateFlags |= flags;

if (mParent != null) {
mParent.invalidate(CHILDREN);
final Parentable parent = getParent();
if (parent != null) {
parent.invalidate(CHILDREN);
}
}

Expand Down Expand Up @@ -443,12 +446,24 @@ final public void setPosition(final PointF position) {
* @param position the position to set
*/
public void setPosition(final float x, final float y) {
// diff check
if (mPosition.x == x && mPosition.y == y) {
return;
}

mPosition.x = x;
mPosition.y = y;
invalidate(POSITION);


}

public void setX(final float x) {
// diff check
if (mPosition.x == x) {
return;
}

mPosition.x = x;
invalidate(POSITION);
}
Expand All @@ -458,6 +473,11 @@ final public float getX() {
}

public void setY(final float y) {
// diff check
if (mPosition.y == y) {
return;
}

mPosition.y = y;
invalidate(POSITION);
}
Expand All @@ -472,6 +492,11 @@ final public float getY() {
* @see #setAlphaTestEnabled(boolean)
*/
public void setZ(final float z) {
// diff check
if (mZ == z) {
return;
}

mZ = z;
invalidate(POSITION);
}
Expand All @@ -481,15 +506,11 @@ final public float getZ() {
}

public void moveTo(final float x, final float y) {
mPosition.x = x;
mPosition.y = y;
invalidate(POSITION);
setPosition(x, y);
}

public void move(final float dx, final float dy) {
mPosition.x += dx;
mPosition.y += dy;
invalidate(POSITION);
setPosition(mPosition.x + dx, mPosition.y + dy);
}

/**
Expand Down Expand Up @@ -538,16 +559,21 @@ public PointF getPivot() {
}

public void setPivot(final PointF pivot) {
mPivot.x = pivot.x;
mPivot.y = pivot.y;

invalidate(PIVOT);
setPivot(pivot.x, pivot.y);
}

public void setPivot(final float x, final float y) {
mPivot.x = x;
mPivot.y = y;

// check center
if (mPivotAtCenter) {
if (Math.abs(x - mSize.x * 0.5f) >= 1 || Math.abs(y - mSize.y * 0.5f) >= 1) {
// no longer center
mPivotAtCenter = false;
}
}

invalidate(PIVOT);
}

Expand All @@ -561,6 +587,10 @@ public void setPivotAtCenter() {
invalidate(PIVOT);
}

public boolean isPivotAtCenter() {
return mPivotAtCenter;
}

/**
* @return the size
*/
Expand Down Expand Up @@ -739,9 +769,9 @@ public GLColor getInheritedColor() {
}

// multiply by parent's attributes
if (mParent != null && mParent instanceof Displayable) {
final Displayable parent = (Displayable) mParent;
final GLColor parentColor = parent.getInheritedColor();
final Parentable parent = getParent();
if (parent instanceof Displayable) {
final GLColor parentColor = ((Displayable) parent).getInheritedColor();
if (parentColor != null) {
mBlendColor.multiply(parentColor);
}
Expand All @@ -750,13 +780,16 @@ public GLColor getInheritedColor() {
return mBlendColor;
}

final public BlendFunc getInheritedBlendFunc() {
public BlendFunc getInheritedBlendFunc() {
if (mBlendFunc != null) {
return mBlendFunc;
} else if (mParent != null && mParent instanceof Displayable) {
return ((Displayable) mParent).getInheritedBlendFunc();
} else {
return null;
final Parentable parent = getParent();
if (parent instanceof Displayable) {
return ((Displayable) parent).getInheritedBlendFunc();
} else {
return null;
}
}
}

Expand Down Expand Up @@ -948,12 +981,13 @@ public boolean removeFromParent() {
final public void localToGlobal(final PointF local, final PointF result) {
result.x = (local == null ? 0 : local.x) + mPosition.x;
result.y = (local == null ? 0 : local.y) + mPosition.y;
if (mParent != null && !(mParent instanceof Scene)) {
mParent.localToGlobal(result, result);
final Parentable parent = getParent();
if (parent != null && !(parent instanceof Scene)) {
parent.localToGlobal(result, result);

if (mParent instanceof DisplayObject) {
if (parent instanceof Displayable) {
// apply parent's origin
final PointF parentOrigin = ((DisplayObject) mParent).getOrigin();
final PointF parentOrigin = ((Displayable) parent).getOrigin();
result.x -= parentOrigin.x;
result.y -= parentOrigin.y;
}
Expand All @@ -967,12 +1001,13 @@ final public void localToGlobal(final PointF local, final PointF result) {
* @param result
*/
final public void globalToLocal(final PointF global, final PointF result) {
if (mParent != null && !(mParent instanceof Scene)) {
mParent.globalToLocal(global, result);
final Parentable parent = getParent();
if (parent != null && !(parent instanceof Scene)) {
parent.globalToLocal(global, result);

if (mParent instanceof DisplayObject) {
if (parent instanceof Displayable) {
// apply parent's origin
final PointF parentOrigin = ((DisplayObject) mParent).getOrigin();
final PointF parentOrigin = ((Displayable) parent).getOrigin();
result.x += parentOrigin.x;
result.y += parentOrigin.y;
}
Expand Down Expand Up @@ -1101,7 +1136,8 @@ final public Matrix getMatrix() {
}

protected Matrix getParentMatrix() {
return mParent != null ? mParent.getMatrix() : null;
final Parentable parent = getParent();
return parent != null ? parent.getMatrix() : null;
}

/**
Expand Down Expand Up @@ -1234,7 +1270,7 @@ public String getId() {
}

public void setId(final String id) {
if (mParent != null) {
if (getParent() != null) {
throw new Pure2DException("Object is already contained. ID cannot be changed!");
}

Expand Down Expand Up @@ -1292,7 +1328,7 @@ public void setXMLAttributes(final XmlPullParser xmlParser, final UIManager mana

final String color = xmlParser.getAttributeValue(null, ATT_COLOR);
if (color != null) {
mColor = new GLColor(Color.parseColor(color));
mColor = new GLColor(Color.parseColor(manager.evalString(color)));
}

final String alpha = xmlParser.getAttributeValue(null, ATT_ALPHA);
Expand Down
Loading