start_ball_x = tank._x+48*Math.cos(angle*Math.PI/180); start_ball_y = tank._y+48*Math.sin(angle*Math.PI/180); cannonball_fired = attachMovie("cannonball", "cannonball_"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y}); cannonball_fired.dirx = Math.cos(angle*Math.PI/180)*firepower; cannonball_fired.diry = Math.sin(angle*Math.PI/180)*firepower; cannonball_fired.onEnterFrame = function() { this.diry += gravity; this._x += this.dirx/30; this._y += this.diry/30; if ((this._y>350) or (ground.hitTest(this._x, this._y, true))) { this.removeMovieClip(); fired--; } }; } } function place_enemy() { enemy_placed = attachMovie("enemy", "enemy", _root.getNextHighestDepth(), {_x:0, _y:350}); enemy_placed.yspeed = 0; enemy_placed.onEnterFrame = function() { this.yspeed += gravity/10; this._x++; while (_root.ground.hitTest(this._x+this._width/2, this._y+this._height, true)) { this._y--; this.yspeed = 0; } if (!_root.ground.hitTest(this._x+this._width/2, this._y+this._height+1, true)) { this._y += this.yspeed; } else { this.yspeed = 0; } if (this._x>500) { this.removeMovieClip(); place_enemy(); } }; }
效果如下:
最后完成。
Mouse.hide();
上一篇:入门:Flash制作图片爆炸效果动画
下一篇:Flash制作好看的影片指导进度条
|