一步一步教你做RPG游戏(1)


  来源: | 作者: | 浏览: | 发送给好友 | 添加到收藏夹
 第一步:导入资料图片

首先在flash中导入人物走路的图片,如下图:

第二步:制作向前后左右走路的影片剪辑

把刚才导入的图片,分别制作成4个影片剪辑a,d,s,w,用来描述走路的过程,如下图

第三步:制作Walk影片剪辑,

在主场景中建立一个walk影片剪辑,在walk中建立8个关键帧,帧标签分别是: Right , Left , Down , Up ,

Right2 , Left2 , Down2 , Up2 前4个关键帧分别放置影片剪辑d,a,s,w ,后面4个关键帧放置相应的静态图片,用来显示人物静止时候的状态.

第四步:加上影子

新建图层yingzi,里面放置一个椭圆形阴影影片剪辑yingzi如下图


第五步:添加AS,让人物走动.

1、   在walk的第一帧加入stop();

2、   对walk加上 ClipEvent如下:

CODE:

[Copy to clipboard]

onClipEvent (keyDown) {

         //定义速度

         var v = 2;

         if (Key.isDown(Key.LEFT)) {

                   if (this._currentframe != "Left") {

                            this.gotoAndStop("Left");

                   }

                   this._x -= v;

         }

         if (Key.isDown(Key.RIGHT)) {

                   if (this._currentframe != "Right") {

                            this.gotoAndStop("Right");

                   }

                   this._x += v;

         }

         if (Key.isDown(Key.DOWN)) {

                   if (this._currentframe != "Down") {

                            this.gotoAndStop("Down");

                   }

                   this._y += v;

         }

         if (Key.isDown(Key.UP)) {

                   if (this._currentframe != "Up") {

                            this.gotoAndStop("Up");

                   }

                   this._y -= v;

         }

}

onClipEvent (keyUp) {

         if (Key.getCode() == 38) {

                   this.gotoAndStop("UP2");

         }

         if (Key.getCode() == 39) {

                   this.gotoAndStop("RIGHT2");

         }

         if (Key.getCode() == 40) {

                   this.gotoAndStop("DOWN2");

         }

         if (Key.getCode() == 37) {

                   this.gotoAndStop("LEFT2");

         }

}

最终效果如下:

当然,这个家伙会满屏跑,在传统的RPG游戏当中,人物应该在屏幕的中央才对,下节我们将讲解如何实现人物在场景中行走。
上一篇
闪动论坛 打印此页 发送给好友 返回顶部