Reputation: 633
How can I call a function to make 3 fish move? This is what I have:
var fillPosition = 10;
for(var i = 0; i < 50; ++i) {
horizontal[i] = fillPosition;
fillPosition += 10;
}
function fish1Swim() {
document.getElementById("fish1").style.left = horizontal[fish1Position] + "px";
++fish1Position;
if (fish1Position == 49)
fish1Position = 0;
}
function startSwimming() {
setInterval(fish1Swim, 100);
}
I am thinking I should var each fish but I really don't understand.
Upvotes: 0
Views: 135
Reputation: 25742
Do not reinvent the wheel, use one of the JavaScript animation libraries here: http://sixrevisions.com/javascript/10-impressive-javascript-animation-frameworks/
and read the js animation tutorial here: http://www.schillmania.com/content/projects/javascript-animation-1/
Upvotes: 2