Jump to content

setPosition not working for spritesheet


Recommended Posts

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++)



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.


Tried different alternatives like ex-


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


  • Recently Browsing   0 members

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