Sign in to follow this  
Tufan

What is the difference between sprite.x and sprite.body.x?

Recommended Posts

I noticed that sprite.x/y doesn't have any effect on player coordinates in Phaser CE v2.7.10. However, sprite.body.x/y works perfectly.

What is sprite.x/y for?

Share this post


Link to post
Share on other sites

The sprite.x/y values correspond to a sprite's visual position. The sprite.body.x/y values correspond to its physics body position. If a sprite has physics enabled, then its body will 'drive' where the sprite appears, and so they'll both be the same. If physics is not enabled, then the sprite will not have a .body property and will only be positionable by its x and y properties.

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

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.