iKest

Wrong render sprite from spritesheet if x,y is not an integer

Recommended Posts

if x or y  is not an integer (for example when using  tweens with Easing.Bounce.Out or arcade physics), then sprite rendered from spritesheet whith shift... How to fix it?

trouble.png

Share this post


Link to post
Share on other sites

The position of a sprite will make no difference to the frame being rendered. What the above looks like is just standard canvas anti-aliasing because you're using sub-pixel values, so it interpolates the pixels for you, producing those nasty side-effects.

The solution? Round your pixels.

Share this post


Link to post
Share on other sites

Thx for explanation. Rounding course is the most obvious solution. It's just not very easy if you dinamically creating a lot of sprites. And where better to do rounding, in update, prerender of render?

Share this post


Link to post
Share on other sites

During motion it doesn't matter so much, it's when it comes to a stop you will notice it.

The renderer has a roundPixels flag, which will round most (but not all) things for you automatically. You can enable it with:

game.renderer.renderSession.roundPixels = true;

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.