0
我不明白爲什麼我的數組中的項目不會沿着y軸向下移動,我希望它們隨機出現在x軸上。這是我的代碼:障礙不會移動
import flash.display.MovieClip;
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.easing.*;
public class obstacleOne extends MovieClip {
private var speed:Number;
private var obstacleOneTypes:Array = ["obstacle1","obstacle2"];
private var thisObstacleOneType:String;
public function obstacleOne() {
// constructor code
// pick a random number between 1 and the amount of types of litter
var randomNumber:uint = Math.ceil(Math.random() * obstacleOneTypes.length);
thisObstacleOneType = obstacleOneTypes[randomNumber - 1];
this.gotoAndStop(randomNumber);
this.x = Math.ceil(Math.random() * 400);
this.y =0 - Math.random()*400;
speed = 4 + (Math.random()*4)
addEventListener(Event.ENTER_FRAME,updateMe);
}
public function caught():void{
// in this function are going to animate the litter removing from the screen using a tween equation
// when it is finished we can remove the object
// now place in a random position on the beach
this.x = Math.ceil(Math.random() * stage.stageWidth);
this.y =0 - Math.random()*2000;
}
private function updateMe(evt:Event):void{
this.y += speed;
if(y>stage.stageHeight){
this.y = 7;
// send an event to main class to subtract score
//stage.dispatchEvent(new Event("hitBottom",true));
}//*/
}
發生了什麼呢? – pkyeck 2012-01-18 21:35:28
如果您發現問題的解決方案,請在此提供,以便其他具有相同問題的人員可以從中受益。謝謝。 – Sbhklr 2012-01-21 11:54:32