Jump to content

Problem with body setSize method


Radem
 Share

Recommended Posts

I am using arcade physics in my game with gravity and tileset. Character can crouch. When it crouches, animation is run and body size is adjusted by method setSize(), problem is, that sometimes character falls down through the tile that it is supposed to collide with. I don't understand, there must be some secret behind that setsize method, because if I remove it, character collides normally when crouches.

Link to comment
Share on other sites

I don't enlarge the body, but I make it smaller and the new bounds of the body doesn't exceed the previous ones.

However, I was blind while debugging. Now I know that it only happens when the character is looking left (is scaled by -1). It doesn't make any sense to me, for the scale is only set to x coordinate, while my problem relates to the vertical direction. It brings another question:

If I want to resize the sprite's body, can I somehow turn the sprite using scale.x property? (without causing the sprite to behave that wrong way). Or do I have to add to the spritesheet flipped images of every frame? That would be really disappointing. Thx for response.

Link to comment
Share on other sites

Ok, solved. I didn't know that when I set scale.x to -1 that width property becomes negative value as well. That leaded into passing negative numbers to setSize() in my method, causing the body to bug. Thx samme for these debug methods, they are very useful and can save some time, perhaps I need to check the documentation more. :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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