android - AndEngine - TimerHandler not providing contact between bodies -


I am making a jumper game responsible for living in jumping jump platforms. I start playing with my character and 3 platforms. The next platform I randomly generate with a timer handler is almost ready, but IM is facing some problems with a timer handler. I use the platform (stationary body) using it spawn platforms in every second.

  Private zeros addplat (int x, int y) {platform = new platform (x, y, vbom, physics world); AttachChild; } Private Wide CreatePlatSpawn () {Float MFFactSpace Dele = 1F; PlatSpawnTimerHandler = New TimerHandler (mEffectSpawnDelay, true, new ITimerCallback () {@Override Public Zero onTimePassed (TimerHandler pTimerHandler) {platformList.add (forums); if (platformList.getLast () Gety ()> = 240 & amp; & Amp; platformList.getLast () of Gety () & lt; 400) {yCoord = (int) (platform.getY () - addNumber.nextInt (160)); else if (platformList.getLast () Gety () Of & lt; 240. & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; GetY ()> = 50) {yCoord = (int) (platform.getY) + addNumber. NextInt (160));} xCoord = (int) (platform.getX) + 200); AdPlat (xCoord, yCoord);}}); ResourcesManager.engine.registerUpdateHandler (platSpawnTimerHandler); }   

I use a variable-foot contact to jump, when it can be positive, otherwise it can not

contact listener here

  Private contact listener contact listener () {ContactListener contactListener = new contact listener () {Public Zero Start Contact (Contact Contact) {Final Stability x1 = contact.getFixtureA (); Final stability x2 = contact .getFixtureB (); If (x1.getBody () getUserData () = Null & amp;!!! X2.getBody () getUserData () = null) .. {If (x2.getBody () getUserData () equals ("player")) {player.increaseFootContacts (); }}} Public Zero End Contacts (Contact Contact) {Final Stability x1 = contact.getFixtureA (); Final stability x2 = contact .getFixtureB (); If (x1.getBody () getUserData () = Null & amp;!!! X2.getBody () getUserData () = null) .. {If (x2.getBody () getUserData () equals ("player") {player.decreaseFootContacts (); }}} Public Zero preSolve (Contact Contact, Manifold Old Manifold) {} ​​Public Zero Post Solve (Contact Contact, Impulse Impulse Impulse) {}}; Return contact listener; }   

Here is the method inside the class player, to jump it

  public zero jump (if (feet contacts & lt; 1) {Return;} Body.setLinearVelocity (New vector 2 (body.getLinearVelocity (.), X, 15));}   

But the first three platform jump operation works perfectly but when It talks to the platforms created by the timerhandle, so it does not work. Can anyone help me

The method for creating the first 3 platforms Dana:?

  Private Zero createFirstPlat () {addPlat (200, 200); AdPlate (400, 300); AdPlate (600, 150);}   < P> class platform  
  increases the public class platform sprite (private body body; public platform (boat px, boat py, vertexBufferObjectManager vbo, PhysicsWorld physicsWorld) {super (px, py, ResourcesManager) .getInstance () platform_region, vbo.); CreatePhysics (physicsWorld); // TODO Automatic Manufacturer Stub} Private Zero CreatePhysics (PhysicsWorld PhysicsWorld) {body = PhysicsFactory.createBoxBody (physicsWorld, this, BodyType.StaticBody, PhysicsFactory.createFixtureDef 0, 0, 0.5f)); Body.setUserData ("forum"); PhysicsWorld.registerPhysicsConnector (New PhysicsConnector (this, body, right, wrong) {@Override Public Zero onUpdate (boat pSecondsElapsed) {super.onUpdate (pSecondsElapsed);}}); }   

}

You should be posting more code where the manual Crate those 3 working platforms as it is possible that the problem is insetUserData which I can not see because you have not even posted your platform class.

Another potential problem is that you do not attach it to the right unit or try to make a problem with the physical disconnector, which you probably do not start

  Public Unit Foreground Line = New Unit ();   

and then attach it to view then use in addPlat

  foregroundLayer.attachChild (forums)   

if it is Paste your platform class that will not help and how you make them for the first three times.

By the way, when you want to control the layers, this is a very good solution. For example, you want some prints to be on the top and some prints are on the background and overlapping should be important. So that you first add the background layer and then the foreground layer after that. At the end you can attach other antivate to those two layers at any time and it will be shown as you expect.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -