语录提交--登陆--注册--论坛交流--站长博客

Flash Rpg 人物行走制作

[作者:来自网络][日期:2007-12-28][导航:Flash教程 >> Flash游戏编程 >> Flash Rpg 人物行走制作]
  

第一步:导入资料图片
首先在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游戏当中,人物应该在屏幕的中央才对,下节我们将讲解如何实现人物在场景中行走。

最终效果如下:当然,这个家伙会满屏跑,在传统的RPG游戏当中,人物应该在屏幕的中央才对,下节我们将讲解如何实现人物在场景中行走。

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游戏当中,人物应该在屏幕的中央才对,下节我们将讲解如何实现人物在场景中行走。

[文章热度:]


上一页:Flash制作简单的拼图游戏教程

下一页:Flash高射炮简单游戏的制作过程

最新话题

网站导航

搜索

网站公告


Copyright 2007 51as.com. Some Rights Reserved.
鄂ICP备07003189号

Powered by: KingCMS 5.0.1.0217