我试图在if语句中切换帧,当"拾取"项目
基本上我有3张地图,每张地图被拾取后,帧应该前进到下一帧。拿起一张地图后,它会前进到下一帧。问题是,当我去拿第二张地图时,它不会推进框架。
这是我的代码:
stage.addEventListener(Event.ENTER_FRAME, growVisible);
function growVisible(grow: Event) {
if (map1.hitTestPoint(character.x,character.y, true)) {
darkness.gotoAndStop(currentFrame + 1);
map1.visible = false;
}
if (map2.hitTestPoint(character.x, character.y, true)) {
darkness.gotoAndStop(currentFrame + 1);
map2.visible = false;
}
if (map3.hitTestPoint(character.x, character.y, true)) {
darkness.gotoAndStop(currentFrame + 1);
map3.visible = false;
}
}
"黑暗"是我试图推进框架的项目。 map1,map2,map3是我接受的项目。
我也试过这样的代码而没有运气:
function growVisible(grow: Event) {
if (map1.hitTestPoint(character.x,character.y, true)) {
darkness.gotoAndStop(2);
map1.visible = false;
if (darkness.currentFrame == 2) {
darkness.gotoAndStop(3);
} else if (darkness.currentFrame == 3) {
darkness.gotoAndStop(4);
}
} if (map2.hitTestPoint(character.x, character.y, true)) {
darkness.gotoAndStop(2);
map2.visible = false;
if (darkness.currentFrame == 2) {
darkness.gotoAndStop(3);
} else if (darkness.currentFrame == 3) {
darkness.gotoAndStop(4);
}
} if (map3.hitTestPoint(character.x, character.y, true)) {
darkness.gotoAndStop(2);
map3.visible = false;
if (darkness.currentFrame == 2) {
darkness.gotoAndStop(3);
} else if (darkness.currentFrame == 3) {
darkness.gotoAndStop(4);
}
}
}
非常感谢任何帮助。
答案 0 :(得分:1)
我相信应该总是说
darkness.gotoAndStop(darkness.currentFrame + 1);
您希望darkness
'时间轴前进,对吗?只是“currentFrame
”指的是当前 MovieClips框架,它总是保持在1我想?