Animation effect:
Click here to download the source file
Frame contents of ball in main scene:
Main scene as:
gun_mc._rotation=-40;
_root.ang=-40;
_root.total=0;
_root.attachmovie ("Fly", "Fly", 10,{_x:random (+) +220,_y:random (220) +10});
Up_btn.onpress=function () {
Turnangle (5);
if (gun_mc._rotation<-85) {
gun_mc._rotation=-85;
}
}
Down_btn.onpress=function () {
Turnangle (-5);
if (gun_mc._rotation>-5) {
gun_mc._rotation=-5;
}
}
function Turnangle (TMP) {
gun_mc._rotation+=-1*tmp;
_root.ang=gun_mc._rotation;
}
Fire_btn.onpress=function () {
if (_root.ball._currentframe==1) {
_root.ball.gotoandplay (2);
}
}
//------------------------------------
First frame in ball:
Stop ();
_visible = false;
Second frame:
var rad =-_root.ang/180*math.pi;
_x = _root.gun_mc._x+80*math.cos (RAD);
_y = _root.gun_mc._y-80*math.sin (RAD);
var Vx = math.sqrt (750) *math.cos (RAD);
var Vy = -1*math.sqrt (750) *math.sin (RAD);
_visible = true;
Third frame:
var Hitmon = this.hittest (_root.fly);
if (Hitmon) {
gotoAndPlay ("Hitbang");
}
_x + Vx;
_y + = Vy;
vy++;
if (_y>=350 | | _x>550) {
gotoAndPlay ("Bang");
}
Trace (1);
Frame four:
gotoAndPlay (_currentframe-1);
Frame 16th:
gotoAndStop (1);
Frame 17th
: _root.fly.removemovieclip ();
_root.total++;
Frame 26th
: _root.attachmovie ("Fly", "Fly", ten, {_x:random (+220), _y:random (220) +10});
gotoAndStop (1);
//------------------------------------------
You can also try.