PDA

View Full Version : [AS2] for loop for a bullet any exopalnations cheers


hansolo
02-24-2008, 12:02 PM
code below from www.flash-game-design.com

is a better way to use a for loop,and deduct the bullet speed from the x postion
Each bullet movieclip's y poistion is deducted by the bullet speed, making it appear to move along.

some of the code i dont uderstand any explanations be great help cheers


var bulletArray =[]
var bulletSpeed = 9;


for (var i = 0; i<bulletArray.length;i++){

bulletArray[i]._y -= bulletSpeed;


please can some 1 explain if this is correct


i is equal to zero;
i is less than bulletArray - what is the bulletArray equal to zero?
.lengh.....unsure what that is ?

i++ increase the bulletArray by 1 ,so is the bullet array 1 now?


on the second line of code is the bulletArray saying Y position
is on the stage at postion zero [i] ?????

how does minus the _y position by decreasing the bullet speed
move the bullet wont the movement just stop

as you can see im confused???

any help or explanation

cheers