日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

由淺入深學(xué)習(xí)Flash制作高射炮游戲_Flash教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:Flash實(shí)例“蝶戀花”制作過程深入剖析
通過這個(gè)蝴蝶在花叢中翻飛的實(shí)例我們可以學(xué)習(xí)Flash圖層、引導(dǎo)線運(yùn)動、幀與補(bǔ)間動畫等技術(shù)。主要使用工具:箭頭工具(選擇工具)、任意變形工具、鉛筆工具。請大

  主要是利用Flash Actionscript一步一步學(xué)習(xí)Flash高射炮簡單游戲的制作過程,最終效果只是一個(gè)簡單的演示,假如你有愛好可以繼續(xù)深入學(xué)習(xí)!

  開篇前,先把所有的演示動畫的源程序提供給大家:

  點(diǎn)擊這里下載本教程中所有演示動畫的源文件(解壓密碼:hl5o.cn)

  第一步:首先簡單的制作一個(gè)鼠標(biāo)動畫,繪制一個(gè)鼠標(biāo)的圖,自己定。然后選擇第一幀輸入下面代碼:

Mouse.hide();
attachMovie("crosshair", "crosshair", 1);
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};

  效果如下:

  第二步:繪制一個(gè)坦克,分成兩部分,如下面:

由淺入深學(xué)習(xí)Flash制作高射炮游戲

  把下面的命名實(shí)例名為tank

  代碼如下:

Mouse.hide();
attachMovie("crosshair", "crosshair", 1);
attachMovie("tank", "tank", 2, {_x:230, _y:350});
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};
tank.onEnterFrame = function() {
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle = 180;
}
if (mousex>=0 && mousey<0) {
angle = 360;
}
this.cannon._rotation = angle*-1;
};

  效果(無角度限制):

  第三步:我這里設(shè)置轉(zhuǎn)動的一定的角度。

Mouse.hide();
attachMovie("crosshair", "crosshair", 1);
attachMovie("tank", "tank", 2, {_x:230, _y:350});
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};
tank.onEnterFrame = function() {
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle = 180;
}
if (mousex>=0 && mousey<0) {
angle = 360;
}
if (angle>160) {
angle = 160;
}
if (angle<20) {
angle = 20;
}
this.cannon._rotation = angle*-1;
};

  效果如下:

  然后是計(jì)算開火的目標(biāo):

Mouse.hide();
attachMovie("crosshair", "crosshair", 1);
attachMovie("tank", "tank", 2, {_x:230, _y:350});
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};
tank.onEnterFrame = function() {
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle = 180;
}
if (mousex>=0 && mousey<0) {
angle = 360;
}
if (angle>160) {
angle = 160;
}
if (angle<20) {
angle = 20;
}
firepower = Math.sqrt(mousex*mousex mousey*mousey);
if (firepower>200) {
firepower = 200;
}
this.cannon._rotation = angle*-1;
};

  開火的制作:

Mouse.hide();
attachMovie("crosshair", "crosshair", 1);
attachMovie("tank", "tank", 2, {_x:230, _y:350});
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};
tank.onEnterFrame = function() {
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle = 180;
}
if (mousex>=0 && mousey<0) {
angle = 360;
}
if (angle>160) {
angle = 160;
}
if (angle<20) {
angle = 20;
}
firepower = Math.sqrt(mousex*mousex mousey*mousey);
if (firepower>200) {
firepower = 200;
}
this.cannon._rotation = angle*-1;
};
function onMouseDown() {
angle = tank.cannon._rotation-1
start_ball_x = tank._x 48*Math.cos(angle*Math.PI/180);
start_ball_y = tank._y 48*Math.sin(angle*Math.PI/180);
attachMovie("cannonball", "cannonball", 3, {_x:start_ball_x, _y:start_ball_y});
}

  效果如下:

  開火出來炮彈:

Mouse.hide();
attachMovie("crosshair", "crosshair", 1);
attachMovie("tank", "tank", 2, {_x:230, _y:350});
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};
tank.onEnterFrame = function() {
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle = 180;
}
if (mousex>=0 && mousey<0) {
angle = 360;
}
if (angle>160) {
angle = 160;
}
if (angle<20) {
angle = 20;
}
firepower = Math.sqrt(mousex*mousex mousey*mousey);
if (firepower>200) {
firepower = 200;
}
this.cannon._rotation = angle*-1;
};
function onMouseDown() {
angle = tank.cannon._rotation-1;
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._x = this.dirx/50;
this._y = this.diry/50;
};
}

  效果如下:

  最后再加以具體的限制一下炮彈:

Mouse.hide();
gravity = 2;
attachMovie("crosshair", "crosshair", 1);
attachMovie("tank", "tank", 2, {_x:230, _y:350});
crosshair.onEnterFrame = function() {
this._x = _xmouse;
this._y = _ymouse;
};
tank.onEnterFrame = function() {
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y)*-1;
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle = 180;
}
if (mousex>=0 && mousey<0) {
angle = 360;
}
if (angle>160) {
angle = 160;
}
if (angle<20) {
angle = 20;
}
firepower = Math.sqrt(mousex*mousex mousey*mousey);
if (firepower>200) {
firepower = 200;
}
this.cannon._rotation = angle*-1;
};
function onMouseDown() {
angle = tank.cannon._rotation-1;
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/50;
this._y = this.diry/50;
};
}

  效果如下:

分享:Flash8制作具有搜索功能的電話本
利用Flash8ActionScript制作一個(gè)簡單的電話本搜索程序。先看效果(姓名中輸入Sven,Michel,Jack,Charly和Ana可以查看到結(jié)果):點(diǎn)擊這里下載源文件(解

/所屬分類:Flash教程/更新時(shí)間:2008-03-05
相關(guān)Flash教程