我爲Android設備創建了一個包含20個關卡的平臺遊戲。每個級別都有不同的行走平臺和具有不同屬性的新敵人。 我有20個按鈕的第一幀,第一個按鈕去第一級(第二幀)第二個按鈕去第二級(第3幀),並一直持續到第21幀的最後一級。 我寫了我所有的代碼在第2幀(第1級)玩家移動,敵人屬性,硬幣,生命等等。 當玩家死亡或玩家完成舞臺時,我會轉到第1幀,即時消息準備點擊第2級按鈕,轉到第2階段3. 那麼,我的代碼中的哪一部分我必須轉移到第二級?平臺遊戲。跳轉到下一幀
這是我的第二幀中的代碼的一部分。 (i顯示了只有一個敵人(medouza)和我移動玩家的控制,因爲是一個大的代碼)
stop();
l_btn.addEventListener(TouchEvent.TOUCH_BEGIN,lbtisdown);
l_btn.addEventListener(TouchEvent.TOUCH_END,lbtisup);
r_btn.addEventListener(TouchEvent.TOUCH_BEGIN,rbtisdown);
r_btn.addEventListener(TouchEvent.TOUCH_END,rbtisup);
j_btn.addEventListener(TouchEvent.TOUCH_BEGIN,jbtisdown);
k_btn.addEventListener(TouchEvent.TOUCH_BEGIN,kbtisdown);
stop_btns.addEventListener(TouchEvent.TOUCH_END,allup);
stop1_btn.addEventListener(TouchEvent.TOUCH_END,jkup);
fire_btn.addEventListener(TouchEvent.TOUCH_BEGIN,fbtisdown);
function lbtisdown(e:TouchEvent)
{
ldown = true;
}
function lbtisup(e:TouchEvent)
{
ldown = false;
}
function rbtisdown(e:TouchEvent)
{
rdown = true;
}
function rbtisup(e:TouchEvent)
{
rdown = false;
}
function kbtisdown(e:TouchEvent)
{
kdown = true;
}
function jbtisdown(e:TouchEvent)
{
if (! jdown && onground && ! dizbl)
{
runJump();
}
jdown = true;
}
function fbtisdown(e:TouchEvent)
{
fdown = true;
}
var movers = new Array(bg.ground.platkat0,bg.ground.plator0,bg.ground.platkat1,bg.ground.plator1,bg.ground .plator2,bg.ground.plator3);
var movedirs = new Array(0,1,0,1,1,1);
var movelimits = new Array([-57.5,60],[1853,2021],[-57.5,243],[1935,2072],[2548,2877],[2982,3073]);
var medouzaArr = new Array();
function addMedouza(med)
{
medouzaArr.push(med);
med.medouza.gotoAndStop(1);
med.xvel = 0;
med.yvel = 0;
med.hitpoints = 20;
med.startAttack = 0;
med.fireAttack = 3;
med.sp = Math.random() * .7 + .7;
med.dir = Math.floor(Math.random() * 2);
med.locksp = med.sp;
}
this.addEventListener(Event.ENTER_FRAME,FramesEvents);
function FramesEvents(e:Event)
{
completeStage();
moveplatforms();
moveMedouza();
phys();
controls();
windowcamera();
}
function moveMedouza()
{
for (var k1=0; k1<medouzaArr.length; k1++)
{
var m = medouzaArr[k1];
m.x += m.xvel;
m.xvel *= .3;
m.y += m.yvel;
m.yvel += GRA;
if (m.x > savvito.x)
{
m.scaleX = -1;
}
if (m.x < savvito.x)
{
m.scaleX = 1;
}
if (m.startAttack > 4)
{
m.fireAttack = 1 + Math.floor(Math.random() * 2);
m.startAttack = 0;
}
if (m.fireAttack == 0)
{
m.medouza.gotoAndStop(1);
}
if (m.fireAttack == 1)
{
m.medouza.gotoAndStop(2);
}
if (m.fireAttack == 2)
{
m.medouza.gotoAndStop(3);
}
if (m.medouza.currentFrame == 1 && m.medouza.medouza_iddle.currentFrame == m.medouza.medouza_iddle.totalFrames)
{
m.startAttack += 1;
}
if (m.medouza.currentFrame == 2 && m.medouza.medouza_jump.currentFrame == m.medouza.medouza_jump.totalFrames)
{
m.fireAttack = 0;
var e = bg.addChild(new enemy1());
e.x = m.x;
e.y = m.y;
}
if (m.medouza.currentFrame == 3 && m.medouza.medouza_attack.currentFrame == m.medouza.medouza_attack.totalFrames)
{
m.fireAttack = 0;
}
if (m.medouza.currentFrame == 3 && m.medouza.medouza_attack.currentFrame == 12)
{
var s = bg.addChild(new parentsmos());
smoshArr.push(s);
s.x = m.x;
s.y = m.y;
if (m.scaleX == 1)
{
s.scaleX = 1;
}
if (m.scaleX == -1)
{
s.scaleX = -1;
}
}
if (savvito.hitTestObject(m.med_hit) && ! savvito.hit && ! die)
{
herohitpoints++;
savvito.hit = true;
savvito.hitcv = 0;
if (savvito.x < m.x)
{
xvel = -8;
}
else
{
xvel = +8;
}
yvel = -6;
}
if (savvito.hero.currentFrame == 4 && savvito.hero.attack.hitTestObject(m.med_box) && savvito.hero.attack.currentFrame == 6)
{
m.hitpoints -= 15 + KnifeDamage;
enemieslifebar.enemiesgreenlife.gotoAndStop(m.hitpoints);
if (m.scaleX == 1)
{
m.x = 700;
}
if (m.scaleX == -1)
{
m.x = 100;
}
}
upPushMedouza(m);
if (m.hitpoints <= 0)
{
addBonusCoins();
bg.stageClear.x = m.x;
bg.stageClear.y = m.y + 7;
medouzaArr.splice(k1,1);
bg.removeChild(m);
return;
}
}
}
function completeStage()
{
if (savvito.hitTestObject(bg.stageClear)&&numKey >= 5)
{
j_btn.removeEventListener(TouchEvent.TOUCH_BEGIN,jbtisdown);
stageDone.gotoAndStop(2);
kdown = false;
ldown = false;
rdown = false;
jdown = false;
dizbl = false;
for (var rk1=0; rk1<medouzaArr.length; rk1++)
{
var rm = medouzaArr[rk1];
medouzaArr.splice(rk1,1);
bg.removeChild(rm);
return;
}
if (medouzaArr.length == 0)
{
goto2();
}
fl_CountDownTimerInstance.removeEventListener(TimerEvent.TIMER, fl_CountDownTimerHandler);
fl_CountDownTimerInstance.stop();
fl_Countstart.removeEventListener(TimerEvent.TIMER, fl_CountDownstart);
}
}
function goto2()
{
medouzaArr.length = 0;
movers.length = 0;
movedirs.length = 0;
movelimits.length = 0;
fl_TimerInstancew.start();
if (fl_SecondsElapsedw > 5 && herohitpoints <= 29)
{
channel1.stop();
this.addEventListener(Event.ENTER_FRAME,empty1);
fl_TimerInstancew.removeEventListener(TimerEvent.TIMER, fl_TimerHandlerw);
fl_TimerInstancew.stop();
}
if (fl_SecondsElapsedw == 3 && herohitpoints < 29)
{
savecoins.data.banksavecoins = coinscount + buycoins;
savecoins.flush();
}
}
function empty1(e:Event)
{
this.removeEventListener(Event.ENTER_FRAME,FramesEvents);
gotoAndStop(2);
}
謝謝你非常匹配。它看起來很聰明。 –