0

我在开发这个蛇和梯子游戏时遇到了这个问题,我非常希望你们能帮助我。我已经创建了董事会和头像。唯一的问题是我不能让化身在梯子上移动,然后随着蛇向下移动。有人可以帮助我吗?我现在非常绝望,感谢大家的帮助,谢谢!

编辑:

这是我到目前为止编写的代码 这里是我迄今为止编写的一些代码..

stop();

var xCoord:Array = [141,251,360,471,580,691,799,910,1019,1127,1238,1238,1127,1019,910,799,691,580,471,360,251,251,360,471,580,691,799,910,1019,1127,1238,1238,1127,1019,910,799,691,580,471,360,251,251,360,471,580,691,799,910,1019,1127,1238,1238,1127,1019,910,799,691,580,471,360,251,251,360,471,580,691,799,910,1019,1127,1238,1238,1127,1019,910,799,691,580,471,360,251,251,360,471,580,691,799,910,1019,1127,1238,1238,1127,1019,910,799,691,580,471,360,251];
var yCoord:Array = [675,670,670,670,670,670,670,670,670,670,670,602,602,602,602,602,602,602,602,602,602,534,534,534,534,534,534,534,534,534,534,466,466,466,466,466,466,466,466,466,466,399,399,399,399,399,399,399,399,399,399,331,331,331,331,331,331,331,331,331,331,262,262,262,262,262,262,262,262,262,262,195,195,195,195,195,195,195,195,195,195,127,127,127,127,127,127,127,127,127,127,60,60,60,60,60,60,60,60,60,60];

var arrSquares:Array = new Array(xCoord.length);

var spaceIndex:Number = 0;

var delay:Number = 400;

var tm:Timer = new Timer(delay);
tm.addEventListener(TimerEvent.TIMER, mover);
tm.addEventListener(TimerEvent.TIMER_COMPLETE, moveDone);

spinner.addEventListener(MouseEvent.CLICK, doSpin);
var total:Number =0;
function doSpin(mevt:MouseEvent):void {
var rn:Number = Math.round(5*Math.random()+1);

txtCount.text = String(rn);
total = total + rn;
txtTotal.text = String(total);



txtCount.visible = true;
spinner.removeEventListener(MouseEvent.CLICK, doSpin);




tm.reset();
tm.repeatCount = rn;
tm.start();

}



function mover(tevt:TimerEvent):void {
spaceIndex = (spaceIndex+1)%(xCoord.length);
chip.x = xCoord[spaceIndex];
chip.y = yCoord[spaceIndex];



}


function moveDone(tevt:TimerEvent):void {
spinner.addEventListener(MouseEvent.CLICK, doSpin);
txtCount.visible = false;

}

我不知道在哪里放置执行附加到芯片(头像)的补间动画的 if 语句

4

1 回答 1

0

好吧,这是我最初的想法。我会用你想要上下移动的角色创建一个动画。为简单起见,先制作一个攀爬动画,然后制作一个坠落动画。这很容易做到,只需在插入关键帧后使用时间轴上的补间选项即可。

看起来您已经创建了动画。现在,他是滑上去还是滑下来取决于你的蛇和梯子在哪里。只有你知道,所以在你板上的那些特定位置(例如,x = 200 和 y = 200)我们希望出现 if 语句。但我们只希望它在您的化身完成移动后发生。可能创建一个新函数并将以下内容添加到 mover 函数中

var checkX:Number = chip.x;
var checkY:Number = chip.y
checkLandingSpace(checkX,checkY); 

现在让我们创建一个函数 checkLandingSpace 来检查我们是在射击还是在梯子上

       function checkLandingSpace(checkX:Number,checkY:Number):void
    {
         if (checkX = (your point) || (another point) //first check all x points...continue like this for all points where a ladder is...the || means or
         {
              if (checkY = (your points....etc)
              {
                   mc_avatarLadder.play(); //choose your instance name to be mc_avatar, then play the tween
              }
         }
    }

或者查看这篇文章以将一个变量等同于数组中的任何元素 如果 [Get Variable] 等于 [Array]

现在为你的梯子写下那个。然后对所有拍摄点执行完全相同的操作。除了,用实例名称 mc_avatarShoot 制作一个新动画,然后说 mc_avatarShoot.play();

之后,确保在两个实例的最后一帧,您只需输入 gotoAndStop(1); 只是为了确保下次你去播放动画时它已经准备好了。

当然,适当地调整你的计时器。这几乎可以做到,可能有一些事情需要针对你自己的游戏进行调整,但是遵循这一点并理解它,你就会得到它。

于 2013-07-24T14:22:00.270 回答