嘿,这个让我难过的每个人。所以我有一个名为的电影剪辑数组shark
,它们从舞台的左侧或右侧添加到舞台。现在,当它们被添加时,我让它们在正 x 位置或负 x 位置移动,因此在水平线上。但是为了使玩家在水流中向前移动并且所有其他物体都经过玩家,我还让鲨鱼移动剪辑阵列在正 y 位置移动,因此垂直向下移动。但是当我这样做时,我的 ENTER_FRAME 中有值,shark
数组中的影片剪辑似乎正在移动对角线,这是我根本不想要的。有谁知道如何解决此问题以使电影剪辑向下移动并在屏幕上呈直线移动。
以下是我目前在shark
课堂上的内容:
private function startPosition():void
{
//Pick the frames for start position
var nRandom:Number = randomNumber(1, 2);
//Setup goto and stop on timeline
this.gotoAndStop(nRandom);
//Pick a random speed
nSharkSpeed = randomNumber(3, 5);
//Pick a random number for start position
var nLeftOrRight:Number = randomNumber(1, 2);
//If our nLeftOrRIght == 1 start on the left side
if (nLeftOrRight == 1)
{
//Start shark on left side and move to right
this.x = (stage.stageWidth / 2) - 240;
sSharkDirection = "R";
}else
{
//Start shark on right side and move to left
this.x = (stage.stageWidth / 2) + 240;
sSharkDirection = "L";
}
//Set y position
this.y = (stage.stageHeight / 2) - 400;
//Move our shark
startMoving();
}
private function startMoving():void
{
addEventListener(Event.ENTER_FRAME, sharkLoop);
}
private function sharkLoop(e:Event):void
{
//test what direction fish is moving in
//If fish is moving right
if (sSharkDirection == "R")
{
//Move Shark right
this.x += nSharkSpeed;
}else
{
//Move Shark left
this.x -= nSharkSpeed;
}
this.y += nSharkSpeed;
}
任何帮助将不胜感激谢谢!