67 lines
1.8 KiB
ActionScript
67 lines
1.8 KiB
ActionScript
package com.arc.dh.objects
|
|
{
|
|
import com.arc.dh.state.HorizontalMode;
|
|
import com.arc.dh.util.Data;
|
|
import com.arc.flixel.ArcSprite;
|
|
import org.flixel.FlxG;
|
|
import org.flixel.FlxObject;
|
|
import org.flixel.FlxPoint;
|
|
|
|
public class Bullet extends ArcSprite
|
|
{
|
|
|
|
protected var _collider:FlxObject;
|
|
|
|
private var _dir:Number;
|
|
|
|
private var _speed:Number;
|
|
|
|
public var damage:int;
|
|
|
|
public function Bullet(param1:Number, param2:Number, param3:Number, param4:Number)
|
|
{
|
|
super(param1,param2);
|
|
velocity.x = param3 * Math.cos(param4);
|
|
velocity.y = param3 * Math.sin(param4);
|
|
this._dir = param4;
|
|
this._speed = param3;
|
|
if(Data.state is HorizontalMode)
|
|
{
|
|
velocity.x += (Data.state as HorizontalMode).camera.velocity.x;
|
|
}
|
|
x += velocity.x * 0.005;
|
|
y += velocity.y * 0.005;
|
|
}
|
|
|
|
override public function update() : void
|
|
{
|
|
if(this.offScreen())
|
|
{
|
|
alive = false;
|
|
exists = false;
|
|
}
|
|
super.update();
|
|
}
|
|
|
|
override public function offScreen() : Boolean
|
|
{
|
|
var _loc1_:FlxPoint = getScreenXY();
|
|
return _loc1_.x < -width || _loc1_.x > FlxG.width || _loc1_.y < -height - 60 || _loc1_.y > FlxG.height + 60;
|
|
}
|
|
|
|
public function setCollider(param1:FlxObject) : void
|
|
{
|
|
this._collider = param1;
|
|
}
|
|
|
|
public function shift(param1:Number, param2:int = 1) : Bullet
|
|
{
|
|
var _loc3_:Number = this._dir + Math.PI / 2 * param2;
|
|
x += this._speed * param1 * Math.cos(_loc3_);
|
|
y += this._speed * param1 * Math.sin(_loc3_);
|
|
return this;
|
|
}
|
|
}
|
|
}
|
|
|