开发者

"one frog jumps" arrays and displayList AS3

I've got an array of 10 frogs, and only one jumps. I want them all to jump together or sequentially. Anything is better than one frog jumping. How do I get all the frogs in my array to jump?

WHAT I WANT

Selectable frogs I can control

alt text http://www.ashcraftband.com/myspace/videodnd/so_____.jpg

//Creates 10 frogs
var enemyArray:Array = new Array();

for (var i:int = 0; i < 10; i++)
{
   var noname:FrogClass = new FrogClass();
   noname.x = i*44; //this will just assign some different x and y value depending on i.
   noname.y = i*22;
   //noname.x = stage.stageWidth/3;
   //noname.y = stage.stageHeight/3;
   enemyAr开发者_运维百科ray.push(noname); //put the enemy into the array
   addChild(noname); //puts it on the stage
}

//MOTION "moves display list item"
var value:Number = 0.0;
addEventListener( Event.ENTER_FRAME, onEnterFrame );
function onEnterFrame( e:Event ):void
{
noname.y = 10 + ( Math.sin( value ) * 44 );
value += 0.1;
}

SYMBOL PROPERTIES

NAME "noname"

CLASS "FrogClass"

PROGRAMING RELEVANT

I want to play with arrays and the displayList.

RELATED

Scattering the frogs or using other motions would be interesting


//MOTION "moves display list item"
var value:Number = 0.0;
addEventListener( Event.ENTER_FRAME, onEnterFrame );
function onEnterFrame( e:Event ):void
{
for (var i:uint = 0; i < enemyArray.length; i++)
{
var enemyFrog:FrogClass = enemyArray[i]; 
enemyFrog.y = 10 + ( Math.sin( value ) * 44 );
}
value += 0.1;
}

This is untested, but should work. You need to move each instance of frog in your array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜