Jump to content

change sprite bounds


dude78
 Share

Recommended Posts

Hello guys. I use:

this.load.atlas('spriteName');

to load a sprite.

 

To see its bounds and body (for interacting with other objects) we can use:

this.debug.body('spriteName');
this.debug.spriteBounds('spriteName');

 

At the beginning these sizes are the same but we can change body size in such a way: (docs)

this.spriteObject.body.setSize(width, height [, offsetX] [, offsetY]);

 

The question: how to change sprite bounds? Is there any way?

 

Thanks in advance.

Link to comment
Share on other sites

  • 2 weeks later...

@dude78 sometimes it looks like this forum is dead :D What do you mean by changing sprite bounds? You cannot change texture size but you can change size of sprite which uses it. Lets say you have 'character.png' image 100x200 pixels size. Once you load it, it will have 100x200 pixel size texture. You can create sprite using this texture and by default it will be also 100x200 but you can easily change its width/height by my_sprite.width =150 or my_sprite.scale.x = 0.7 to make its width 100*0.7 = 70 pixels. That will change sprite's bounds... also you can directly change x/y propery of sprite to move it around screen and that will also affect bounds. If I understand your question wrongly, just let me know.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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