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

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

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

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

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

首先按Ctrl J修改屬性。

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

創(chuàng)建一個(gè)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);
}
};

  演示效果如下。

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

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

添加一個(gè)物體,來(lái)實(shí)驗(yàn)碰撞檢測(cè)。添加如下Action到主場(chǎ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);
_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í)動(dòng)畫效果
入門者寫的教程面向入門者,讓我們一起成為高手吧!本教程得到了終極討厭大師的鼎力幫助,在此謝謝!先看效果(為了方便演示,我把時(shí)間設(shè)置成了10秒鐘的倒計(jì)時(shí)

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