1
Ask a Question / Re: What does speed mean?
« on: November 29, 2013, 02:50:32 pm »
There you go, this is the code.
Code: [Select]
public dynamic class StartBalls extends SceneScript
{
//Expose your attributes to StencylWorks like this
[Attribute(id="1", name="Display Name", desc="An Attribute")]
public var attributeName:String;
//Then in the constructor or init(), add it to the nameMap like this
//nameMap["Display Name"] = "attributeName";
//This lets API calls using attribute names to use the display name
//Do all actor initialization here
var balls:Array = new Array();
var frames:int = 5;
override public function init():void
{
addWhenUpdatedListener(null, update);
addWhenDrawingListener(null, draw);
for (var i:int=1; i <= 5; i++)
{
var thisBall:Actor = createActor(getActorTypeByName("Ball"),0,32+i*32,MIDDLE);
thisBall.setXVelocity(i*16);
balls.push(thisBall);
}
}
//This is executed every frame of the game
public function update(list:Array):void
{
if (frames > 0)
{
for each (var ball:* in balls)
{
print(ball.getX());
if (ball.getX() > 320)
balls.remove(ball);
}
print("----------");
frames--;
}
}
public function draw(list:Array, g:Graphics, x:Number, y:Number):void
{
}
public function handleCollision(list:Array, event:Collision):void
{
}
//Leave this alone. Do your initializing inside init()
public function StartBalls(ignore:*, scene:GameState)
{
super(scene);
}
}