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

More explicit onManaged* Exceptions #212

Open
wants to merge 1 commit into
base: GLES2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 27 additions & 10 deletions src/org/andengine/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1223,14 +1223,19 @@ public String toString() {

@Override
public void toString(final StringBuilder pStringBuilder) {
pStringBuilder.append(this.getClass().getSimpleName());
pStringBuilder.append(this.getClass().getName());

if((this.mChildren != null) && (this.mChildren.size() > 0)) {
pStringBuilder.append(" [");
final SmartList<IEntity> entities = this.mChildren;
for(int i = 0; i < entities.size(); i++) {
entities.get(i).toString(pStringBuilder);
if(i < (entities.size() - 1)) {
final IEntity lEntity = entities.get(i);
if (lEntity == null) {
pStringBuilder.append("null");
} else {
lEntity.toString(pStringBuilder);
}
if(i < entities.size() - 1) {
pStringBuilder.append(", ");
}
}
Expand Down Expand Up @@ -1363,11 +1368,15 @@ protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {

{ /* Draw children behind this Entity. */
for(; i < childCount; i++) {
final IEntity child = children.get(i);
if(child.getZIndex() < 0) {
child.onDraw(pGLState, pCamera);
} else {
break;
try {
final IEntity child = children.get(i);
if(child.getZIndex() < 0) {
child.onDraw(pGLState, pCamera);
} else {
break;
}
} catch (RuntimeException e) {
throw new RuntimeException("onManagedDraw(...) entity='" + this.getClass().getName() + "' KO during onDraw of child " + i + " (" + toString() + ")", e);
}
}
}
Expand All @@ -1379,7 +1388,11 @@ protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {

{ /* Draw children in front of this Entity. */
for(; i < childCount; i++) {
children.get(i).onDraw(pGLState, pCamera);
try {
children.get(i).onDraw(pGLState, pCamera);
} catch (RuntimeException e) {
throw new RuntimeException("onManagedDraw(...) entity='" + this.getClass().getName() + "' KO during onDraw of child " + i + " (" + toString() + ")", e);
}
}
}
}
Expand All @@ -1399,7 +1412,11 @@ protected void onManagedUpdate(final float pSecondsElapsed) {
final SmartList<IEntity> entities = this.mChildren;
final int entityCount = entities.size();
for(int i = 0; i < entityCount; i++) {
entities.get(i).onUpdate(pSecondsElapsed);
try {
entities.get(i).onUpdate(pSecondsElapsed);
} catch (RuntimeException e) {
throw new RuntimeException("onManagedUpdate(...) entity='" + this.getClass().getName() + "' KO during onUpdate of child " + i + " (" + toString() + ")", e);
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/org/andengine/entity/sprite/batch/SpriteGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ protected boolean onUpdateSpriteBatch() {
} else {
final int childCount = children.size();
for(int i = 0; i < childCount; i++) {
this.drawWithoutChecks((Sprite)children.get(i));
try {
this.drawWithoutChecks((Sprite)children.get(i));
} catch (RuntimeException e) {
throw new RuntimeException("onUpdateSpriteBatch(...) entity='" + this.getClass().getName() + "' KO during onDraw of child " + i + " (" + toString() + ")", e);
}
}
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion src/org/andengine/ui/activity/BaseGameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ private void callGameResumedOnUIThread() {
BaseGameActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
BaseGameActivity.this.onResumeGame();
if (isGameLoaded()) {
BaseGameActivity.this.onResumeGame();
}
}
});
}
Expand Down