Madigan Posted October 14, 2013 Share Posted October 14, 2013 Hey guys, I feel kind of dumb for this, but I'm having trouble setting my sprite's position. I'm trying to make the game world "loop" over the screen edges (i.e. things that go off the left side of the screen appear on the right). However, Phaser won't let me set the position. Any idea why? When I run this code, I get the sprite's position, and then the new position (so I know the variable is changing). Then, the second time it runs, its like the position hasn't changed:console.log(player.position.y);player.position.y = game.height;console.log(player.position.y); Outputs something like:-316320-317320-318320I'm using 1.0.7, and I have reproduced the problem on both Chrome and FireFox. Link to comment Share on other sites More sharing options...
Travis Posted October 14, 2013 Share Posted October 14, 2013 So, unless they changed something in 1.7 (I don't think they touched sprite positioning...), you change the sprites position with .x and .y versus position.x and position.y. So your code would be: player.y = game.height; That should work, it's working for me in 1.6 Link to comment Share on other sites More sharing options...
rich Posted October 14, 2013 Share Posted October 14, 2013 Correct, you use the x/y properties to change sprite placement (unless you are giving it motion, in which case you apply that to the sprite.body). Unless you have enabled collideWorldBounds of course, in which case the sprite would be reset back inside the world again if you try and move it out ZED 1 Link to comment Share on other sites More sharing options...
Dimple Posted April 9, 2015 Share Posted April 9, 2015 @rich So if my image is balloonImage which is an image object and set to tween. While the image is moving, at some random point of time I want to know the position of that image, should I call this: Link to comment Share on other sites More sharing options...
Dimple Posted April 9, 2015 Share Posted April 9, 2015 @rich So if I have an image object balloonImage which is set to tween. While the image is moving, at some random point of time I want to know the position of the image, I should call this: balloonImage.body.position.x and balloonImage.body.position.y Is it so? Link to comment Share on other sites More sharing options...
Recommended Posts