ylluminarious Posted October 2, 2014 Share Posted October 2, 2014 Hi all, I have a sprite in my game that changes size at certain points in the game. It changes size via the `sprite.body.setSize` method. Unfortunately, it seems that the sprite is unaffected by objects that it should collide with whilst it is in the process of changing size. This makes sense because the sprite's boundaries are in a state of flux during the process of a size change, but this is bad because my user can take advantage of this and move through walls. I'm not sure how to get the sprite to be susceptible to collision while in the process of changing size. Does anyone know a way around this? Link to comment Share on other sites More sharing options...
ylluminarious Posted October 3, 2014 Author Share Posted October 3, 2014 I've also posted this on the Game Dev StackExchange, in case anyone wants to answer it there.http://gamedev.stackexchange.com/questions/84342/a-problem-with-collision-when-a-sprite-changes-size-phaser-framework Link to comment Share on other sites More sharing options...
j0hnskot Posted October 3, 2014 Share Posted October 3, 2014 Did you try checking for overlap instead of collision? Link to comment Share on other sites More sharing options...
ylluminarious Posted October 3, 2014 Author Share Posted October 3, 2014 @j0hnskot I just tried checking for overlap, as well as collision. The good news is that the sprite does detect overlap, even when it's changing size. The bad news is that the sprite can still move through walls. Link to comment Share on other sites More sharing options...
j0hnskot Posted October 3, 2014 Share Posted October 3, 2014 There may be an easier solution for that but here it is.You can enable an overlap check when the player is resizing ,see at which side is the wall relative to the sprite and then move the sprite away from the wall until the resizing is complete. After that you can disable the overlap check. Link to comment Share on other sites More sharing options...
ylluminarious Posted October 3, 2014 Author Share Posted October 3, 2014 @j0hnskot Thanks, I'll try that out. If anyone has any other ideas for making this work, feel free to post it Link to comment Share on other sites More sharing options...
Recommended Posts