Hi every, this is the most headache issue I’ve ever met. I was trying to create an arcade sprite (let’s say at 0,0) If I created the sprite inside the ‘create’ function of the scene, it will be placed at the correct location. If I created the sprite inside the ‘update’ function, things went really strange. I was trying to use a fixed update loop, so I created something like this:
update (time : number, delta : number) {
this.frameTime += delta;
//create an arcade sprite circle at (0,0)
//if created here, the sprite will be placed at a correct location
//this.testPlayer.createTestCircle();
//create the sprite after 20ms passed
if(this.frameTime > 20){
//create an arcade sprite circle at (0,0)
//if created in this if, the sprite will be placed at a wrong location (it was offset to -40, -40, but the sprite position still showing x = 0, y = 0)
this.testPlayer.createTestCircle();
this.frameTime = 0;
}
}
If I don’t use Arcade Physics (like this.add.sprite) then things work fine. But as soon as I used Arcade Physics, and apply body to the sprite. It will be rendered at the wrong location for some reason. It seems like at the moment the sprite was created, it was correct. But when it comes to the next frame, the sprite was pushed to another location nearby.
I have been working on this issue for 4 hours now, but still have no idea.
Any ideas?