Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/326831207709036545
Improved formatting.
Source Link
Laurent Couvidou
  • 9.2k
  • 2
  • 42
  • 58

I use a DigitalOnScreenControl DigitalOnScreenControl (knob with a four-directional arrow control) to move the entity and the entity which is bound to a physicsHandlerphysicsHandler.

physicsHandler.setEntity(sprite);
sprite.registerUpdateHandler(physicsHandler);

From the DigitalOnScreenControlDigitalOnScreenControl, I know which direction I want my sprite to move. Inside its overridden onControlChangeonControlChange function, I call a function animateSpriteanimateSprite that checks which direction I chose. Based on the direction, I animate my sprite differently.

PROBLEM:Problem: I want to automatically move the sprite to a specific location on the scene, say at coordinates (207, 305). My sprite is at (100, 305, which means it has to move down by 107 pixels. 

How do I tell the physicsHandlerphysicsHandler to move the sprite down by 107 pixels? My animateSpriteanimateSprite method will take care of animating the sprite's downward motion.

Thank you for your input!

I use a DigitalOnScreenControl (knob with a four-directional arrow control) to move the entity and the entity which is bound to a physicsHandler.

physicsHandler.setEntity(sprite);
sprite.registerUpdateHandler(physicsHandler);

From the DigitalOnScreenControl, I know which direction I want my sprite to move. Inside its overridden onControlChange function, I call a function animateSprite that checks which direction I chose. Based on the direction, I animate my sprite differently.

PROBLEM: I want to automatically move the sprite to a specific location on the scene, say at coordinates (207, 305). My sprite is at (100, 305, which means it has to move down by 107 pixels. How do I tell the physicsHandler to move the sprite down by 107 pixels? My animateSprite method will take care of animating the sprite's downward motion.

Thank you for your input!

I use a DigitalOnScreenControl (knob with a four-directional arrow control) to move the entity and the entity which is bound to a physicsHandler.

physicsHandler.setEntity(sprite);
sprite.registerUpdateHandler(physicsHandler);

From the DigitalOnScreenControl, I know which direction I want my sprite to move. Inside its overridden onControlChange function, I call a function animateSprite that checks which direction I chose. Based on the direction, I animate my sprite differently.

Problem: I want to automatically move the sprite to a specific location on the scene, say at coordinates (207, 305). My sprite is at (100, 305, which means it has to move down by 107 pixels. 

How do I tell the physicsHandler to move the sprite down by 107 pixels? My animateSprite method will take care of animating the sprite's downward motion.

Source Link
Shailen
  • 181
  • 1
  • 7

How to move a sprite automatically using a physicsHandler in Andengine?

I use a DigitalOnScreenControl (knob with a four-directional arrow control) to move the entity and the entity which is bound to a physicsHandler.

physicsHandler.setEntity(sprite);
sprite.registerUpdateHandler(physicsHandler);

From the DigitalOnScreenControl, I know which direction I want my sprite to move. Inside its overridden onControlChange function, I call a function animateSprite that checks which direction I chose. Based on the direction, I animate my sprite differently.

PROBLEM: I want to automatically move the sprite to a specific location on the scene, say at coordinates (207, 305). My sprite is at (100, 305, which means it has to move down by 107 pixels. How do I tell the physicsHandler to move the sprite down by 107 pixels? My animateSprite method will take care of animating the sprite's downward motion.

Thank you for your input!