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

hhw897

hhw897

2016-01-29 12:38

高级游戏制作:Flash制作物体弹跳电脑游戏,高级游戏制作:Flash制作物体弹跳电脑游戏

  Flash制作物体弹跳电脑游戏,这是一种背景不动的一个物体可以弹跳,可以左右走动的小游戏。比较基础的游戏。

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

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

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

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

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

回到主场景,我们用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 Array(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://m.tulaoshi.com/fjc/)[next]

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

展开更多 50%)
分享

猜你喜欢

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

flash教程
高级游戏制作:Flash制作物体弹跳电脑游戏

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

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

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Flash制作空战游戏(4)

flash教程
Flash制作空战游戏(4)

Photoshop制作物体发光效果

电脑网络
Photoshop制作物体发光效果

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

Flash制作空战游戏(三)

flash教程
Flash制作空战游戏(三)

Flash制作空战游戏(2)

flash教程
Flash制作空战游戏(2)

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

判断点与多边形的状态(位置)

判断点与多边形的状态(位置)

《真流行之神》奖杯一览 探索都市传说的真相

《真流行之神》奖杯一览 探索都市传说的真相
下拉加载更多内容 ↓