当前位置: 首页 > 图文教程 > Flash动画 > Flash动画制作 > Flash MX 编程深层次应用-Flash射击游戏(6)

Flash动画制作
Flash MV音乐和字幕的制作(下)
最强大的Flash反编译工具(一)
Flash制作空战游戏(四)
Flash菜单轻松做 上
Flash菜单轻松做 下
Flash 三小时上手
Flash 三小时上手(二)
Flash 三小时上手(三)
Flash5 位移操作(三)
Flash层的运用(三)
Flash层的运用(四)
实例学用Flash MX增强的AS功能(1)
Flash MX的自由变形工具(2)
Flash MX 视频导入功能详解(1)
Flash MX 文本工具手册(1)
Flash MX 文本工具手册(2)
Flash MX 文本工具手册(3)
Flash MX 文本工具手册(4)
Flash MX 文本工具手册(5)
Flash MX 文本工具手册(6)

Flash动画制作 中的 Flash MX 编程深层次应用-Flash射击游戏(6)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-22   浏览: 100 ::
收藏到网摘: n/a

6.2 游戏制作(前台)(5)

    

6.2.6  游戏的初始化程序

至此,敌人部分基本上讲完,下面讲讲游戏的初始化。也许大家会问,怎么,游戏快讲完了才讲初始化啊,游戏初始化不是应该在游戏一开始就对各种物体、目标、声音效果、得分进行初始设置吗,为什么不在本章的前面部分讲啊?其实道理很简单,这么复杂的游戏,如果一开始就讲初始化,读者根本就不知这些初始化语句有何用处。还不如等游戏的具体内容讲得差不多了再列出初始化程序,这样会更加容易理解这些代码的实际含义。具体程序如下:

//设置是否为不死版

nodead = false;

//我的得分

your_score = 0;

//游戏正式开始设置游戏画面的长宽,还有我的飞机数

play_width = 300;

play_height = 400;

//设置飞船移动的4个边界

play_left = 5;

play_right = 295;

play_top = 25;

play_bottom = 395;

my_plane_number = 3;

for (i=5;i>=my_plane_number;i--) {

  eval("my_plane_num_"+i)._visible = false;

}

//设置复制的影片数组

play_plane = new Array();

//我的生命值为50

      

my_blood = 50;

//我的射击声音

my_shot = new Sound();

my_shot.attachSound("my_plane_shot");

//背景循环音乐的声音

bgsound = new Sound();

bgsound.attachSound("loop");

bgsound.setVolume(80);

//得到令牌的声音

get_pai = new Sound();

get_pai.attachSound("get");

//我死的声音

my_dead = new Sound();

my_dead.attachSound("dead");

//大怪发出一个子弹的声音

big_enemy_one_sound = new Sound();

big_e