欧美日韩精品在线,国内精品久久久久久久久,一级毛片恃级毛片直播,清纯唯美亚洲综合欧美色

Flash游戲制作基礎(chǔ):跟隨鼠標(biāo)的曲線_Flash教程

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

推薦:用Flash AS簡單制作可以任意拖動的四邊形
用FlashActionscript簡單制作可以任意拖動的四邊形,是制作游戲的一個基礎(chǔ)程序。打開Flash,首先將屬性改為30fps然后新建立一個組建laser,設(shè)置效果如下。然

Flash游戲制作基礎(chǔ),跟隨鼠標(biāo)的曲線,曲線和其它物體之間進(jìn)行碰撞檢測。友情提示文章末尾提供Fla源文件的下載。

首先按Ctrl J修改屬性。

Flash游戲制作基礎(chǔ):跟隨鼠標(biāo)的曲線

創(chuàng)建一個MC,如下圖。是放大到800%的效果。

Flash游戲制作基礎(chǔ):跟隨鼠標(biāo)的曲線

然后直接使用鼠標(biāo)跟隨,下面代碼直接放到第一幀,創(chuàng)建軌跡。

tail_len = 2;
tail_nodes = 100;
nodes = new Array();
_root.attachMovie("the_head", "the_head", 1, {_x:250, _y:200});
_root.createEmptyMovieClip("the_tail", 2);
for (x=1; x<tail_nodes; x ) {
nodes[x] = {x:the_head._x, y:the_head._y};
}
the_head.onEnterFrame = function() {
this._x = _root._xmouse;
this._y = _root._ymouse;
the_tail.clear();
the_tail.lineStyle(2, 0x00ff00);
the_tail.moveTo(the_head._x, the_head._y);
nodes[0] = {x:the_head._x, y:the_head._y};
for (var x = 1; x<tail_nodes-1; x) {
rotation = Math.atan2(nodes[x].y-nodes[x-1].y, nodes[x].x-nodes[x-1].x);
pos_x = nodes[x-1].x tail_len*Math.cos(rotation);
pos_y = nodes[x-1].y tail_len*Math.sin(rotation);
nodes[x] = {x:pos_x, y:pos_y};
the_tail.lineTo(pos_x, pos_y);
}
};

  演示效果如下。

然后再建立一個MC設(shè)置如下,做一面墻來檢測碰撞。

Flash游戲制作基礎(chǔ):跟隨鼠標(biāo)的曲線

添加一個物體,來實(shí)驗(yàn)碰撞檢測。添加如下Action到主場景第一幀。

tail_len = 2;
tail_nodes = 100;
nodes = new Array();
_root.attachMovie("the_head", "the_head", 1, {_x:250, _y:200});
_root.createEmptyMovieClip("the_tail", 2);
_root.attachMovie("wall", "wall", 3, {_x:250, _y:200});
for (x=1; x<tail_nodes; x ) {
nodes[x] = {x:the_head._x, y:the_head._y};
}
the_head.onEnterFrame = function() {
this._x = _root._xmouse;
this._y = _root._ymouse;
the_tail.clear();
the_tail.lineStyle(2, 0x00ff00);
the_tail.moveTo(the_head._x, the_head._y);
nodes[0] = {x:the_head._x, y:the_head._y};
for (var x = 1; x<tail_nodes-1; x) {
rotation = Math.atan2(nodes[x].y-nodes[x-1].y, nodes[x].x-nodes[x-1].x);
pos_x = nodes[x-1].x tail_len*Math.cos(rotation);
pos_y = nodes[x-1].y tail_len*Math.sin(rotation);
nodes[x] = {x:pos_x, y:pos_y};
if (wall.hitTest(pos_x, pos_y, true)) {
the_tail.lineStyle(2, 0xff0000);
}
the_tail.lineTo(pos_x, pos_y);
}
};

  效果如下。

點(diǎn)擊這里下載源文件

分享:用Flash制作課件中的倒計(jì)時動畫效果
入門者寫的教程面向入門者,讓我們一起成為高手吧!本教程得到了終極討厭大師的鼎力幫助,在此謝謝!先看效果(為了方便演示,我把時間設(shè)置成了10秒鐘的倒計(jì)時

來源:網(wǎng)頁教學(xué)網(wǎng)//所屬分類:Flash教程/更新時間:2008-03-05
相關(guān)Flash教程