Last visited

Profiles

Forums

Everything posted by keke

Using P2 Physics, what's the best way to move a sprite, similar to sprite.body.moveRight, sprite.body.moveLeft but in parallel with another sprite that has a rotation (which constantly changes).
I want to be able to move the purple line up and down along the yellow line, in parallel and at a fixed distance while they both rotate.
Anya ideas?
Thanks

Hi,
When changing from one state to another any updates to a p2 body's velocity seems to be ignored.
I've created the following codepen to illustrate:
http://codepen.io/klas/pen/qbMXmm
When changing from FirstState to SecondState (with clearWorld = false ) the player sprite stops moving when using p2 physics even though velocity is still applied in the update function in SecondState. If I change to Arcade physics everything works as expected and the player sprite keeps moving. Maybe I'm just missing something how p2 physics work? Is there some kind of reset needed between states? I've tried re-enabling p2 physics for the player sprite in the Second State with no luck.
Update: If I call revive() on the player sprite in the create function of SecondState it seems to solve the issue. Not sure why that is?
Updated codepen: http://codepen.io/klas/pen/VeGMpq
Thanks