查看完整版本: [原创菜鸟教程]传统移动教程

Kof-X 2005-7-31 17:15

[原创菜鸟教程]传统移动教程

[upload=swf]UploadFile/2005-7/200573191420452.sw<BR>
<br>
[upload=fla]viewFile.asp?ID=259873[/upload]<BR>嗯,第二个教程,混个积分。
<br>
见下

Kof-X 2005-7-31 17:29

首先:将背景改成大小300X301[em13]
<br>
        [upload=bmp]UploadFile/2005-7/200573191940929.bmp[/upload]
<br>
划一个坦克的形状:
<br>
<BR>将它选中按F8变成影片剪辑。
<br>
再新建一个影片剪辑第一帧是空白帧;代码:
<br>
[quote]
<br>
stop();<BR>[/quote]
<br>
第二帧是这样的:
<br>
        <BR>

Kof-X 2005-7-31 17:47

新建一个影片剪辑,将两个东东从库里拖出来:
<br>
       
<br>
那个小点点是开炮用的[em13],将它命名huo。
<br>
到了最关键的地方了,也是代码最长的地方。将刚做的MC拖入场景,输入代码:
<br>
[quote]
<br>
onClipEvent (load) {<BR>        Speed = 5;<BR>}<BR>onClipEvent (enterFrame) {<BR>        if (Key.isDown(Key.LEFT) and !Key.isDown(Key.RIGHT)) {<BR>                _x -= Speed;<BR>                _rotation = 270;<BR>        }<BR>        if (Key.isDown(Key.RIGHT) and !Key.isDown(Key.LEFT)) {<BR>                _x += Speed;<BR>                _rotation = 90;<BR>        }<BR>        if (Key.isDown(Key.UP) and !Key.isDown(Key.DOWN)) {<BR>                _y -= Speed;<BR>                _rotation = 0;<BR>        }<BR>        if (Key.isDown(Key.DOWN) and !Key.isDown(Key.UP)) {<BR>                _y += Speed;<BR>                _rotation = 180;<BR>        }<BR>        if (Key.isDown(Key.LEFT) and Key.isDown(Key.UP) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.DOWN)) {<BR>                _rotation = 315;<BR>        }<BR>        if (Key.isDown(Key.RIGHT) and Key.isDown(Key.UP) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.DOWN)) {<BR>                _rotation = 45;<BR>        }<BR>        if (Key.isDown(Key.LEFT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.UP)) {<BR>                _rotation = 225;<BR>        }<BR>        if (Key.isDown(Key.RIGHT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.UP)) {<BR>                _rotation = 135;<BR>        }<BR>        if (_x&lt;-5) {<BR>                _x = 301;<BR>        }<BR>        if (_x&gt;306) {<BR>                _x = 0;<BR>        }<BR>        if (_y&gt;305) {<BR>                _y = 0;<BR>        }<BR>        if (_y&lt;-5) {<BR>                _y = 300;<BR>        }<BR>        if (Key.isDown(Key.SPACE)) {<BR>                with (huo) {<BR>                        gotoAndPlay(2);<BR>                }<BR>        }<BR>}
<br>
[/quote]
<br>
别怕怕,这么长的代码很简单。下面是注释过的代码:
<br>
[quote]
<br>
onClipEvent (load) {<BR>        Speed = 5;
<br>
//始初话Speed(本来想用Sp,一想是骂人,哈哈)<BR>}<BR>onClipEvent (enterFrame) {<BR>        if (Key.isDown(Key.LEFT) and !Key.isDown(Key.RIGHT))//避免错误 {<BR>                _x -= Speed;<BR>                _rotation = 270;<BR>        }<BR>        if (Key.isDown(Key.RIGHT) and !Key.isDown(Key.LEFT)) //避免错误{<BR>                _x += Speed;<BR>                _rotation = 90;<BR>        }<BR>        if (Key.isDown(Key.UP) and !Key.isDown(Key.DOWN)) //避免错误{<BR>                _y -= Speed;<BR>                _rotation = 0;<BR>        }<BR>        if (Key.isDown(Key.DOWN) and !Key.isDown(Key.UP)) //避免错误{<BR>                _y += Speed;<BR>                _rotation = 180;<BR>        }<BR>        //下为设置_rotation的代码,只需复制更改一下即可
<br>
if (Key.isDown(Key.LEFT) and Key.isDown(Key.UP) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.DOWN)) {<BR>                _rotation = 315;<BR>        }<BR>        if (Key.isDown(Key.RIGHT) and Key.isDown(Key.UP) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.DOWN)) {<BR>                _rotation = 45;<BR>        }<BR>        if (Key.isDown(Key.LEFT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.RIGHT) and !Key.isDown(Key.UP)) {<BR>                _rotation = 225;<BR>        }<BR>        if (Key.isDown(Key.RIGHT) and Key.isDown(Key.DOWN) and !Key.isDown(Key.LEFT) and !Key.isDown(Key.UP)) {<BR>                _rotation = 135;<BR>        }
<br>
//一下为转圈代码,为什么要加5呢,因为这5可以使其更自然一点<BR>        if (_x&lt;-5) {<BR>                _x = 301;<BR>        }<BR>        if (_x&gt;306) {<BR>                _x = 0;<BR>        }<BR>        if (_y&gt;305) {<BR>                _y = 0;<BR>        }<BR>        if (_y&lt;-5) {<BR>                _y = 300;<BR>        }
<br>
//一下为开火,所以我刚才教你们做火<BR>        if (Key.isDown(Key.SPACE)) {<BR>                with (huo) {<BR>                        gotoAndPlay(2);<BR>                }<BR>        }<BR>}
<br><br>
[/quote]
<br>
嗯,主要搞完了,美化一下:
<br>
       
<br>
<BR>[em12]大家觉得不好可以更改一下

l小闪虫l 2005-7-31 20:34

应该加上轮子<IMG src="http://www.flash8.net/bbs/Skins/default/topicface/face2.gif">
<br>
不错,顶个

Kof-X 2005-7-31 20:44

为什么没有加分<IMG src="http://www.flash8.net/bbs/Skins/default/topicface/face12.gif">

Kof-X 2005-7-31 20:46

<IMG src="http://www.flash8.net/bbs/Skins/default/topicface/face14.gif">闪虫,你是不是经常在教程区发教程啊??

Kof-X 2005-8-1 02:13

自己顶<IMG src="http://www.flash8.net/bbs/Skins/default/topicface/face5.gif">

紫鬼儿 2007-9-6 20:47

好东西

顶一下

kentlee 2008-7-4 08:28

我是初初級菜鳥,
馬上跟做試試看~
謝謝~

笑笑K 2008-7-4 09:43

:loveliness: :loveliness:

零下九度冰 2008-7-4 12:29

新来的,来学习了,谢谢!

kuanggong889 2008-7-7 09:39

charles_ccs 2008-7-7 10:29

不懂程序啊~支持楼主
页: [1]
查看完整版本: [原创菜鸟教程]传统移动教程