Jump to content

Setting the body.x


Dream Of Sleeping
 Share

Recommended Posts

I'm having all sorts of weird issues with collision.

 

Do I set the sprite.x and sprite.y when I need to position it? Because setting the sprite.body.x often doesn't seem to work. If I alter the sprite.x and the move the body.x do I take into consideration the anchor being centered in the sprite? Do I set the body.x - the sprites half width?

 

 

Link to comment
Share on other sites

There are much better people than me at this sort of thing but as a suggestion if you need to move the sprite outside the physics could you kill it and then revive it in the correct place. This sort of thing happens all the time in sprite pooling so should work. If anything is placed where two bodies interest though they'll whizz off. (They do in P2 anyway). When I had this I always calculated a point a set distance and rotation from one of the sprites so that the two bodies would not intersect when the new one was added.

I hope this is some help or that somebody with a better idea contributes.

EDIT:

This thread incicates that what you are doing will have weird effects:

http://www.html5gamedevs.com/topic/3258-cant-set-xy-of-sprites-only-velocity/

Link to comment
Share on other sites

Thank you very much for replying. I'm actually starting to really depressed about this, so I might just not finish this time. I wish I'd used create js now.

 

That thread was useful thank you. If I do continue in the morning will just have to write my own functions to test collision. I can't possibly understand why the sprite. intersect method always returns true.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...