SamSnowy Posted January 11, 2018 Share Posted January 11, 2018 So my problem is that I have a sprite that is giving me 0 for sprite.world.x and sprite.world.y (although it clearly isn't at 0,0). What's weird is that printing out the sprite.world.x gives 0 at first but adding a delay of 50ms it gives me the correct position (in case you're wondering nothing is happening during the delay) Below is the code snippet that i am using (just to be 100% sure). Basically I have a group (located at a certain position) with a specific rotation that has a sprite (the one I'm having issues with) at a certain location. Quote var newR = game.add.sprite(300, 200, 'rocketFuel'); //Group var myGroup = game.add.group(); myGroup.x = 600; myGroup.y = 200; myGroup.angle = 20; myGroup.add(newR); console.log(newR.world.x); this.game.time.events.add(50, function () { console.log(newR.world.x); } ,this); The first printed out value is 300 (which obviously isn't true). I added a delay of 50 ms after the last line then printed out newR.world.x and got the correct value (813). The provided code snippet is the last thing I have in my create function (and the update function is empty). As stated previously nothing is happening by the time the delay starts till it ends (I am only left with the preload function). Link to comment Share on other sites More sharing options...
Recommended Posts