//上升的太阳的起始坐标值用随机数来生成 function firstPos() {
_root.sun._x = 50+random(450); //太阳起始点的X轴坐标 _root.sun._y = 370; //太阳起始点的Y轴坐标 dirX = random(5)-random(6); //太阳的方向
}
测试结果成功。而太阳的方向可以根据需要进行改变。 太阳被击中的代码处理如下:
//弓箭进入第10帧时检测到与太阳碰撞
_root.onEnterFrame = function() {
if (_root.tan._currentframe == 10) {
hit = _root.tan.hitTest(_root.sun); if (hit) {
/*mySunSound = new Sound();
mySunSound.loadSound(\_root.DIESUN.gotoAndPlay(2); firstPos(); _root.score++;
//太阳中箭之后被打落 with (_root.diesun) { }
_x = _root.tan._x; _y = _root.tan._y; gotoAndPlay(2);
}
};
}
};
太阳飞出舞台的代码如下:
//指定飞出舞台的太阳的起始位置和方向 _root.sun.onEnterFrame = function() { };
(4)测试目标瞄准影片剪辑代替鼠标的代码,代码如下:
//target影片剪辑替换鼠标指针 _root.target.onMouseMove = function() {
this._x = _root._xmouse; this._y = _root._ymouse; updateAfterEvent(); };
(5)启动计时器代码的测试:
//启动计时器
if (_root.sun._y<0 || _root.sun._x<0 || _root.sun._x>550) {
firstPos();
} else { }
_root.sun._y -= (3+random(2)); _root.sun._x += dirX;
_root.target.onEnterFrame = function() {
time++;
_root.timer = 30-int(time/30); if (_root.timer == 0) { } };
(6)对游戏结束时的代码的测试:
结束游戏时,所有音效要结束,代码如下: stopAllSounds();
_root.gotoAndStop(3);
结束游戏时,出现重新开始按钮,对其进行监听,代码如下: _root.replay.onEnterFrame = function() { };
游戏结束时,对分数进行判断,并根据相应需要出现相应按钮。当得分多于
if (_root.tan._currentframe == 10) { }
hit2 = _root.replay.hitTest(_root.tan); if (hit2) { }
_root.gotoAndStop(1); _root.yun1.gotoAndPlay(1); _root.yun2.gotoAndPlay(1);
目标分数,则出现下一关按钮和主菜单按钮。否则,只出现主菜单按钮。代码如下:
if (score>=10) {
}
/*my11Sound = new Sound();
my11Sound.loadSound(\_root.GXNGGL.gotoAndPlay(2); _root.nextbutton._x = 325; _root.nextbutton._y = 251;
_root.nextbutton.onRollOver = function() { };
_root.menubutton._x = 230; _root.menubutton._y = 251;
_root.menubutton.onRollOver = function() { };
Mouse.show(); Mouse.show();
if (score<10) {
}
/*my10Sound = new Sound();
my10Sound.loadSound(\_root.QBYFQ_ZLYCB.gotoAndPlay(2); _root.menubutton._x = 276; _root.menubutton._y = 251;
_root.menubutton.onRollOver = function() { };
Mouse.show();
三:关数2测试
关数2除了关数1的测试外,主要增加了对小鸟的代码测试。 (1)小鸟的初始位置代码如下: //小鸟的起始位置用随机数生成
function firstBird1() {
_root.bird1._x = -120;
_root.bird1._y = 100+random(250); }
小鸟飞出舞台的位置代码如下: //指定飞出舞台的小鸟的起始位置和方向 _root.bird1.onEnterFrame = function() { };
if (_root.bird1._x>600) {
firstBird1();
}else{ }
_root.bird1._x += 5;
_root.bird1._y+=(random(3)-2);
相关推荐: