高级游戏制作:Flash制作物体弹跳电脑游戏 (1)

2016-03-18 19:23 2 1 收藏

只要你有一台电脑或者手机,都能关注图老师为大家精心推荐的高级游戏制作:Flash制作物体弹跳电脑游戏 (1),手机电脑控们准备好了吗?一起看过来吧!

【 tulaoshi.com - FLASH 】

  Flash制作物体弹跳电脑游戏,这是一种背景不动的一个物体可以弹跳,可以左右走动的小游戏。比较基础的游戏。在文章的最后提供所有演示的Flash源文件。

看不到动画效果的朋友请去这里观看:http://bbs./thread-99274-1-1.html

  启动Flash,首先修改文档属性。

  首先制作两个电影剪辑一个是背景,绘制一个矩形小块来当背景。加入AS为:stop(),让它开始就停止。

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/flash/)

  另外一个是运动的物体,给大家截图如下。

回到主场景,我们用Actionscript来实现其它效果。在主场景的第一帧直接加入下面代码:  xspeed = 0;
yspeed = 0;
max_yspeed = 16;
gravity = 1;
walk_speed = 4;
level = new Array();
_root.createEmptyMovieClip("lev", _root.getNextHighestDepth());
level[0] = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
level[1] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[2] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[3] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[4] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[5] = new Awww.tulaoshi.comrray(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1);
level[6] = new Array(1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[7] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[8] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[9] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[10] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[11] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[12] = new Array(1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[13] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
level[14] = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
for (y=0; y=14; y++) {
 for (x=0; x=24; x++) {
  if (level[y][x] != 0) {
   place_brick = lev.attachMovie("block", "block_"+lev.getNextHighestDepth(), lev.getNextHighestDepth(), {_x:x*20+10, _y:y*20+10});
   place_brick.gotoAndStop(level[y][x]);
  }
 }
}
_root.attachMovie("player", "player", _root.getNextHighestDepth(), {_x:40, _y:40});
player.onEnterFrame = function() {
 yspeed += gravity;
 if (yspeedmax_yspeed) {
  yspeed = max_yspeed;
 }
 if (Key.isDown(Key.LEFT)) {
  xspeed = -walk_speed;
 }
 if (Key.isDown(Key.RIGHT)) {
  xspeed = walk_speed;
 }
 while (_root.lev.hitTest(this._x, this._y+this._height/2-1+yspeed, true)) {
  yspeed--;
 }
 while (_root.lev.hitTest(this._x-this._width/2+1+xspeed, this._y, true)) {
  xspeed++;
 }
 while (_root.lev.hitTest(this._x+this._width/2-1+xspeed, this._y, true)) {
  xspeed--;
 }
 this._y += yspeed;
 this._x += xspeed;
 xspeed = 0;
};

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/flash/)

[1] 200806/12956_2.html'>[2] 200806/12956_2.html'>下一页

  上面代码实现的效果是会出现一幅不动的背景。效果如下。 

200806/12956.html'>上一页  200806/12956.html'>[1] [2] 

来源:https://www.tulaoshi.com/n/20160318/1895181.html

延伸阅读
标签: flash教程
二、元件的制作 1.新建一个场景“场景1”,选择“修改”菜单的“文档”选项,在弹出的文档属性对话框中背景色修改为黑色,尺寸就用默认的550*400,帧频为50 fps。 2.建立一个影片剪辑(以下简称MC),命名为“plane”,这个影片剪辑是作为用来控制的战斗机的。在该影片剪辑中的第一帧中插入一个关键帧,在编辑区中画一...
标签: flash教程
8.右击“ball”剪辑,在“动作”面板里设置代码 onClipEvent (load) { speed=15; } onClipEvent (enterFrame) { if(!_root.shipDead){ //如果战斗机的生命值大于0 if(this.hitTest(_root.ship)){ //敌机发出的炮弹击中战斗机 _root.ship.play(); ...
标签: flash教程
8.右击“ball”剪辑,在“动作”面板里设置代码 onClipEvent (load) { speed=15; } onClipEvent (enterFrame) { if(!_root.shipDead){ //如果战斗机的生命值大于0 if(this.hitTest(_root.ship)){ //敌机发出的炮弹击中战斗机 _root.ship.play(); ...
标签: flash教程
三 、代码控制 1.回到主场景,把第一个图层改名为“start”,在第一帧中插入关键帧,帧动作为: function clean() { for (i in _root) { _root[i].removeMovieClip(); } } _root.clean(); stop(); clean函数用来删除所有多余的影片剪辑,它的功能在第一次运行时没...
标签: flash教程
二、元件的制作 1.新建一个场景“场景1”,选择“修改”菜单的“文档”选项,在弹出的文档属性对话框中背景色修改为黑色,尺寸就用默认的550*400,帧频为50 fps。 2.建立一个影片剪辑(以下简称MC),命名为“plane”,这个影片剪辑是作为用来控制的战斗机的。在该影片剪辑中的第一帧中插入一个关键帧,在编辑区中画一个...