I found myself confused again while experimenting with flashy was hoping you wonderful people may have the answer once again :)!.
I wanted a sprite to move round on the screen when a play button was pushed. I have a left and a right button which store strings “left” or “right” into the next positions of an empty array called history.
When i push the play button i want i want the sprite to move either left or right according to what commands are in the array. My code just seems to play one single command and then stops when i hit play again it just repeats the same command.
Is there any way to make it play through all commands in the array one after another?
Here’s the loop that i was trying to use.
if (historyPlay == true)
{
for (var i = 0; i< history.length; i++)
{
switch (history*) {
case "left" :
if (sprite.facing == "N") {
sprite.facing = "W";
} else if (sprite.facing == "W") {
sprite.facing = "S";
} else if (sprite.facing == "S") {
sprite.facing = "E";
} else if (sprite.facing == "E") {
sprite.facing = "N";
}
dir = "left"
this.moving = true
break;
case "right" :
if (sprite.facing == "N") {
sprite.facing = "E";
} else if (sprite.facing == "E") {
sprite.facing = "S";
} else if (sprite.facing == "S") {
sprite.facing = "W";
} else if (sprite.facing == "W") {
sprite.facing = "N";
}
dir = "left"
this.moving = true
break;
}
}
historyPlay = false;
}
Thanks in advanced!