two bugs found in AndEngine

  ... in the unlikely case you discovered a bug, post it here.

two bugs found in AndEngine

Postby dimi52588 » Fri Apr 06, 2012 4:18 pm

Actually, i am quite a green finger in the field of game engine and English. i started to read the code of Andengine with the examples they provided a few days ago. I found it fabulous fantastic cause i''ve made a few games without even knowing the andengine can barely provide the entire functions of them.
When i tried to code the MovingBallExample in the package of org.anddev.andengine.examples. I just create a new java file and copy all the code in that example and fix some typical error and run the project. when the app get started in my phone i can see a ball move directly to the right-corner. but unexpected when the ball attach the right corner of the screen . it get stacked and can't move any more. I wonder why ? You know it's hard for a beginner to find bugs when he know nothing about it even harder without any notes. But i found where gone wrong eventually.

this is the Ball declared:

private static class Ball extends AnimatedSprite {
private final PhysicsHandler mPhysicsHandler; // P1

public Ball(final float pX, final float pY, final TiledTextureRegion pTextureRegion) {
super(pX, pY, pTextureRegion);
this.mPhysicsHandler = new PhysicsHandler(this);
this.registerUpdateHandler(this.mPhysicsHandler); // P2
}
// .... i delete some codes cause they doesn't count.
}

you can see at the line of P1, A PhysicsHandler was declare and be registered by Ball at line of P2. when turn to the
method of loadSecen() you can see there is another PhysicsHandler delclared and registered.

final Ball ball = new Ball(centerX, centerY, this.mFaceTextureRegion);
final PhysicsHandler physicsHandler = new PhysicsHandler(ball);
ball.registerUpdateHandler(physicsHandler);
physicsHandler.setVelocity(DEMO_VELOCITY, DEMO_VELOCITY);

but the latter PhysicsHandler didn't override the method of this:
protected void onManagedUpdate(final float pSecondsElapsed) {
if(this.mX < 0) {
this.mPhysicsHandler.setVelocityX(DEMO_VELOCITY);
} else if(this.mX + this.getWidth() > CAMERA_WIDTH) {
this.mPhysicsHandler.setVelocityX(-DEMO_VELOCITY);
}

if(this.mY < 0) {
this.mPhysicsHandler.setVelocityY(DEMO_VELOCITY);
} else if(this.mY + this.getHeight() > CAMERA_HEIGHT) {
this.mPhysicsHandler.setVelocityY(-DEMO_VELOCITY);
}

super.onManagedUpdate(pSecondsElapsed);
}

when you found that , it can be very easy for you to correct them.

Another bug make me quit confused when i am resting the CustomFontExample. I create a new java file and copy the codes into it too. But when i am run the project . a lethal error occured with the info of Stack over flow when run getFontManager().loadFonts();

I click the link and turn to the core code of andengine and i found this in BaseGameActivity:
public FontManager getFontManager() {
return this.getFontManager();
}
this is a typical method who call itself. so stack overflow.

so i potentially add an mEngine between this and the method like : return this.mEngine.getFontManager();
it works.

all in all. Andengine is nice work and i hope it will become better for all of us.
dimi52588
 
Posts: 1
Joined: Fri Apr 06, 2012 3:37 pm

Re: two bugs found in AndEngine

Postby ChemicalFlash » Sun Aug 12, 2012 12:59 am

Did you made a github pull request yet ?
ChemicalFlash
 
Posts: 2
Joined: Sun Aug 12, 2012 12:51 am

Re: two bugs found in AndEngine

Postby kavenGw » Sat Nov 10, 2012 10:29 am

If you can write this by Chinese,I will very happy! :D
Because my english is not very well!
kavenGw
 
Posts: 4
Joined: Thu Nov 08, 2012 1:41 am


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest