Snakes and Ladders AS3 ..电影剪辑如何爬上梯子?

时间:2013-07-24 14:01:59

标签: actionscript-3 flash-cs6

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

编辑:

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

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语句(头像)

1 个答案:

答案 0 :(得分:0)

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

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

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
              }
         }
    }

或者查看此帖子,将一个变量等同于数组If [Get Variable] is equal to [Array]

中的任何元素

现在为你的梯子写下那个。然后对你所有的射击点做同样的事情。除此之外,制作一个实例名称为mc_avatarShoot的新动画,然后说mc_avatarShoot.play();

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

当然,请适当调整计时器。这应该是这样做的,可能有一些事情要调整你自己的游戏,但遵循这个并理解它,你会得到它。