我一直试图解决这个问题几个小时,无论我做什么,我都无法理解。我收集所有硬币后,我的游戏中的门户网站将被解锁。门户网站已被锁定,但当我查看硬币时,它既不会添加变量,也不会通过实例名称coin1 coin2和硬币3删除影片剪辑。有人可以帮助我吗?
如果删除影片剪辑不需要_root我已经尝试过没有它我知道这不是问题。
var openportal = 0;
function moveStuff() {
//-Very long code that is working.
}
if (ball_mc.hitTest(coin1._x, coin1._y)) {
removeMovieClip(_root.coin1);
var openportal = openportal + 1;
}
if (ball_mc.hitTest(coin2._x, coin2._y)) {
removeMovieClip(_root.coin2);
var openportal = openportal + 1;
}
if (ball_mc.hitTest(coin3._x, coin3._y)) {
removeMovieClip(_root.coin3);
var openportal = openportal + 1;
}
if (openportal >= 3){
if (goal1_mc.hitTest(ball_mc._x, ball_mc._y)) {
gotoAndStop(2);
}
}
ball_mc.onEnterFrame = moveStuff;
答案 0 :(得分:0)
试试这个:
var openportal = 0;
function moveStuff() {
//-Very long code that is working.
}
if (ball_mc.hitTest(coin1._x, coin1._y)) {
_root.removeMovieClip(coin1);
openportal++;
}
if (ball_mc.hitTest(coin2._x, coin2._y)) {
_root.removeMovieClip(coin2);
openportal++;
}
if (ball_mc.hitTest(coin3._x, coin3._y)) {
_root.removeMovieClip(coin3);
openportal++;
}
if (openportal >= 3){
if (goal1_mc.hitTest(ball_mc._x, ball_mc._y)) {
gotoAndStop(2);
}
}
ball_mc.onEnterFrame = moveStuff;