The following code just 'hangs up' my game, I am using javascript with craftyjs
.. I think I am doing very noob mistake which is resulting into infinite loop ..
var trigger_de_movement=true;
pl.animate('PlayerMovingLeft', 1, 1); //this function starts animation named PlayerMovingLeft for 1 frame and repeates 1 time..
while (trigger_de_movement) {/*if animation is not playing, type time and go out and stop the loop*/
if (!pl.isPlaying('PlayerMovingLeft')) {//checks if animation is playing for pl(ayer)
var d=new Date();
putMessage(d.getSeconds()+"."+d.getMilliseconds()); //this function puts message
trigger_de_movement=false; //to make while loop not run forever
}
}
The problem is,
If the
If statement
fails, then the loop will be infinite, because the variabletrigger_de_movement
is true always until the if statement becomes true. If it is false, the loop is infinite. So better you change yourwhile to If
and check what happening