sandeep2d Posted July 20, 2020 Share Posted July 20, 2020 Trying to change position of spritesheet object in incremental manner; But it is not working.. Lets consider this object name is player;And it is defined in global scope. And position change code is as follows for(let i=1;i<10;i++) { window.player.setPosition(x+i*10,y+i*10); var dt = new Date(); while ((new Date()) - dt <= 1000) { /* Do nothing */ } } But when this code executes for starting 9 time player remains in starting position. And on 10th iteration it directly changed position and displayed in last position. Looking for the help for identifying the possible mistake. Note Tried different alternatives like ex- 1)emit 2)Executing this code inside update function. 3)Javascript closure concept. But so far not get any success for the same. Link to comment Share on other sites More sharing options...
Recommended Posts