我做了一個非常基本的乒乓遊戲(在工作),我的問題是,球移動「模糊」..我增加幀率,但它似乎還沒有確定..任何想法?乒乓遊戲示例
package src {
import flash.display.*;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.events.*;
import flash.events.MouseEvent;
import flash.net.*;
import flash.filters.*;
import flash.text.*;
import flash.xml.*;
import flash.geom.*;
public dynamic class pong00 extends Sprite{
public var playerA:pongPlayer = new pongPlayer();
public var playerB:pongPlayer = new pongPlayer();
public var ball01:Ball00 = new Ball00();
public var ballDegree:Number = 45;
public var ballAngelRadian:Number = 0;
public var ballColisionStage:Boolean = false;
public var ballAngelRadianVector:Number = 1;
public var ballSpeed = 16;
public function pong00():void{
addChild(playerA);
addChild(playerB);
addChild(ball01);
ballAngelRadian = (ballDegree * Math.PI/180); stageOrginizer();
}
private function stageOrginizer():void{ // put on the stage
tita_txt.text = " Ready "; // .. a text box on stage ..
playerA.x = 20; playerB.x = stage.stageWidth - 20;
playerA.y = playerB.y = stage.stageHeight/2;
ball01.x = stage.stageWidth/2;
ball01.y = stage.stageHeight/2;
stage.addEventListener(MouseEvent.MOUSE_MOVE, io);
stage.addEventListener(Event.ENTER_FRAME, FL);
}
public function io(evt:MouseEvent):void{ //// mouse
if (ball01.x < (stage.stageWidth/2)){
playerA.y = mouseY;
}else{
playerB.y = mouseY;
}
}
public function FL(evt:Event):void{ /// stage enter frame
if (!(ballColisionStage)){
ball01.x -= ballAngelRadianVector * (Math.cos(ballAngelRadian) * ballSpeed);
ball01.y -= ballAngelRadianVector * (Math.sin(ballAngelRadian) * ballSpeed);
}
if ((ball01.x < 0) || (ball01.x > stage.stageWidth)){
tita_txt.text = " ooops !!! "; // .. a text box on stage ..
impact(0);
}
if ((ball01.y < 0) || (ball01.y > stage.stageHeight)){
impact(180);
}
if((ball01.hitTestObject(playerB)) || (ball01.hitTestObject(playerA))){
tita_txt.text = "";// .. atext box on stage ..
impact(0);
}
}
public function impact(fee:int):void{
ballAngelRadianVector = -ballAngelRadianVector;
ballDegree = fee - ballDegree ;
ballAngelRadian = (ballDegree * Math.PI/180);
}
}
}
不能真正編譯這個 - 你可以上傳的SWF或東西,並提供一個鏈接,所以我可以看到你的意思? http://www.filedropper.com/ – Marty 2011-06-10 05:14:42
http://www.filedropper.com/pong00 – 2011-06-10 05:20:47
你對我的回答不滿意嗎? – Marty 2011-06-10 06:18:11