Jump to content

Sprite body size transform


DWboutin
 Share

Recommended Posts

Hi,

 

I got my sprite, who is 58 x 74 and i set it body at

this.sprite.body.setSize(30, 63, 6, 11);

It's a character, so when i press the left button i scale it at -1 in X. But i don't know how i can adjust the body size.

post-5686-0-20703200-1388786826.png

There's a screenshot of both position, how can i adjust the left one?

 

Thank you

Link to comment
Share on other sites

And why you are settings body for it?
IF physic enabled, it should have  body as sprite size square already.

I guess if you want that particular size ,you can try to  setSize of a body again ,with new x and ,y on -1 scale.

Link to comment
Share on other sites

sprite.body.x and sprite.body.y can be changed if you want. This probably isn't the best idea, as you can have your sprite's body teleport inside other collision bodies, and this isn't cool.

 

A somewhat better way to do it (and what I usually do) is to center your sprite's image in the exact middle of the frame, so that way when you flip back and forth the body doesn't need to move at all.

 

Cheers!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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