Jump to content

Tween sprite without changing its hitbox (arcade physics)


Cawrtz
 Share

Recommended Posts

Hi

 

I would like to tween my sprite when it falls on a platform to make it look like a slime (increase its width and decrease its height, then back to normal).

The problem is that I've enabled Arcade physics on it, and the body (body.width, body.height) is always adjusting to its visual size (sprite properties .width and .height).

game.add.tween(this).to({     width: currentWidth + 10,     height: currentHeight - 10}.onComplete.add(tweenBackToNormalSize);

That creates opportunities to glitch underneath platforms and many other unwanted side effects.

 

Is there a way I can get this effect without changing the hitbox ?

 

Thanks in advance!

Yann

Link to comment
Share on other sites

Hi drhayes, thanks for your answer!

I used scale instead of my width and height calculations

Unfortunately, it stills affects the physics body...

 

Maybe I could use another (visible) sprite that follows the (hidden) sprite body to bypass the issue?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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