Jump to content

Can't set x/y of sprites, only velocity


Stephen304
 Share

Recommended Posts

So I have a sprite for the player basically the same way as tutorials:

    player = game.add.sprite(32, game.world.height - 150, 'man');    player.body.bounce.y = 0;    player.body.gravity.y = 6;    player.body.collideWorldBounds = true;
And I know I can set velocity with
player.body.velocity.x = 150;

But how can I teleport the player? I have tried:

player.body.x = 50;

But it seems to get reverted back instantly to the original coordinate.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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