Game Development Reference
In-Depth Information
import flash.display.Shape;
import flash.geom.Point;
import flash.filters.GlowFilter;
public class BlitArrayPlayerFollowMouse extends BasicBlitArrayObject{
public var xMove:int;
public var yMove:int;
private var xChange:int;
private var yChange:int;
private var radians:Number;
private var degrees:int;
private var drawingCanvas:Shape = new Shape();
public var shipBitmapData:BitmapData = new BitmapData(32, 32, true, 0x00000000);
public var shieldBitmapData:BitmapData = new BitmapData(32, 32, true, 0x00000000);
public var shieldRender:Boolean = false;
public var shieldCount:int = 0;
public var shieldLife:int = 5;
public function BlitArrayPlayerFollowMouse(xMin:int,xMax:int, yMin:int, yMax:int ) {
super(xMin, xMax, yMin, yMax);
}
public function update(mousePositionX:Number, mousePositionY:Number,
delay:int,step:Number=1):void {
radians = Math.atan2((mousePositionY)-y,(mousePositionX)-x);
degrees= (radians * (180 / Math.PI));
yChange= (mousePositionY-y);
xChange= (mousePositionX-x);
yMove=(yChange/delay)*step;
xMove=(xChange/delay)*step;
nextY+=yMove;
nextX+=xMove;
if (nextX > xMax) {
nextX = xMax;
}else if (nextX < +xMin) {
nextX = xMin;
}
if (nextY > yMax) {
nextY = yMax;
}else if (nextY < yMin) {
nextY = yMin;
}
frame = degrees;
Search WWH ::




Custom Search