|
Flash制作红外线引导导弹爆炸视觉效果(3) fragment_mc.cacheAsBitmap = true; fragment_mc.onEnterFrame = function():Void { this._x += this.speedX; this._y += this.speedY; if (this._x < gLEFT this._x > gRIGHT this._y < gTOP this._y > gBOTTOM) { this.removeMovieClip(); } }; } }
/* FUNCTION: Creates and initializes heat-seeking missiles */ createMissile.maxSpeed = 30; createMissile.accel = 2; function createMissile(target_mc:MovieClip, xPos:Number, yPos:Number):Void { var depth:Number = _root.getNextHighestDepth(); var missile_mc:MovieClip = attachMovie("Missile", "missile" + depth, depth); missile_mc._x = xPos; missile_mc._y = yPos; missile_mc.speed = 0; missile_mc.setRotation = function():Void { var dy:Number = target_mc._y - this._y; var dx:Number = target_mc._x - this._x; this._rotation = rad2deg(Math.atan2(dy, dx)); }; missile_mc.onEnterFrame = function():Void { this.setRotation(); if (this.speed < createMissile.maxSpeed) { this.speed += createMissile.accel; } this._x += Math.cos(deg2rad(this._rotation)) * this.speed; this._y += Math.sin(deg2rad(this._rotation)) * this.speed; if (this.hitTest(target_mc)) { explosion(target_mc._x, target_mc._y); this.removeMovieClip(); } }; }
/* MAIN PROGRAM LOGIC */ var gameBG_mc:MovieClip = _root.createEmptyMovieClip("gameBG", 0);
|