flash on 2012-3-16
♥0 |
Line 47 |
Modified 2012-03-16 19:56:04 |
MIT License
archived:2017-03-20 01:25:29
ActionScript3 source code
/**
* Copyright MMMMMonchi ( http://wonderfl.net/user/MMMMMonchi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hrLj
*/
package {
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
{
private var bullets:Array;
private const MAX:int =200;
public function Main()
{
bullets = new Array();
for (var i:int = 0; i < MAX; i++)
{
var bullet:Bullet = new Bullet(Math.random() * 104000000, 30,232,232, Math.random() * 10 - 5, Math.random() * 10 - 5);
addChild(bullet);
bullets.push(bullet);
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
for (var i:int = 0; i < bullets.length; i++)
{
bullets[i].move(i);
}
}
}
}
import flash.display.Sprite;
class Bullet extends Sprite
{ public var vx:Number;
public var vy:Number;
public function Bullet(color:int, radius:int, x:int, y:int,vx:Number,vy:Number)
{
graphics.beginFill(color);
graphics.drawCircle(0, 0, radius);
graphics.endFill();
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
}
public function move(num:int=3):void
{
this.x += vx;
this.y += vy;
}
}