flash素材、flash片头、flash特效、flash源码,flash相册等flash资源都是本站的重要flash素材请大家支持新丁flash素材网!
首页 | 片头欣赏 | Banner 欣赏 | Flash 特效 | 网站欣赏 | 黄色笑话 | 技术文档 | 视频教程 | 网页模板 | flash小游戏 | 源码下载 | 相关下载 | 声音下载 |
flash Action应用 您当前的位置是:首页 >> 技术文档 >> flash Action应用 >> 详细内容
利用Flash制作精彩的迷宫游戏
加入时间:2007-8-3 浏览:30 录入:Flash资源网 来源:网络
网页教学网:在以前的教程中我们讲解了利用Flash制作游戏的一些方法,比如碰撞的检测等,在这个教程中我们利用以前学的知识创建一个不错的迷宫游戏!该教程主要是Flash利用材质和遮照创建真实的小球动画的延续,利用创建好的小球滚动动画制作迷宫游戏。

  在这篇教程中没有新的知识,就是利用一个舞台(地图),然后还有一个运动的小球实现的一个小的Flash游戏。

  一共制作了两个迷宫动画效果。

  一、背景不动的迷宫游戏

  准备好一幅背景之后,直接输入下面代码。

level = new Array();
_root.attachMovie("starz", "starz", 1);
_root.createEmptyMovieClip("bricks", 2);
level[0] = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0);
level[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1);
level[2] = new Array(1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1);
level[3] = new Array(1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1);
level[4] = new Array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
level[5] = new Array(1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1);
level[6] = new Array(1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1);
level[7] = new Array(1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1);
level[8] = new Array(1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1);
level[9] = new Array(1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1);
level[10] = new Array(0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1);
for (y=0; y<=10; y++) {
    for (x=0; x<=11; x++) {
        if (level[y][x] == 1) {
            place_brick = bricks.attachMovie("brick", "brick_"+bricks.getNextHighestDepth(), bricks.getNextHighestDepth(), {_x:x*40+30, _y:y*40+30});
        }
    }
}
_root.attachMovie("ball", "ball", _root.getNextHighestDepth(), {_x:30, _y:30});
ball.texture.setMask(ball.ball_itself);
power = 0.4;
yspeed = 0;
xspeed = 0;
friction = 0.99;
ball.onEnterFrame = function() {
    if (Key.isDown(Key.LEFT)) {
        xspeed -= power;
    }
    if (Key.isDown(Key.RIGHT)) {
        xspeed += power;
    }
    if (Key.isDown(Key.UP)) {
        yspeed -= power;
    }
    if (Key.isDown(Key.DOWN)) {
        yspeed += power;
    }
    xspeed *= friction;
    yspeed *= friction;
    this._y += yspeed;
    this._x += xspeed;
    this.texture._y += yspeed;
    this.texture._x += xspeed;
    if (this.texture._x>53) {
        this.texture._x -= 63;
    }
    if (this.texture._x<-53) {
        this.texture._x += 63;
    }
    if (this.texture._y>53) {
        this.texture._y -= 63;
    }
    if (this.texture._y<-53) {
        this.texture._y += 63;
    }
    brick_x = Math.floor((this._x-10)/40);
    brick_y = Math.floor((this._y-10)/40);
    if (level[brick_y][brick_x]!=1) {
        this._x = 30;
        this._y = 30;
        xspeed = 0;
        yspeed = 0;
    }
};

关于我们 | 联系方式 | 广告赞助 | 免责声明 | 站点留言 | 友情链接 | 推荐站点
Copyright 2007-2008 新丁flash资源(flash素材)网 All Rights Reserved
新丁flash资源(flash素材)网 保留所有权利 未经许可请勿任意转载或复制使用 
请使用1024*768分辨率浏览本站以达到浏览新丁flash资源(flash素材)网的最佳视觉效果
新丁flash资源(flash素材)网中所有的解压密码均为:www.qnflash.com
粤ICP备08010396号