Ich bin ein Anfänger bei Action Script 3 und derzeit ein grundlegendes Spiel der springenden Ball entwickeln. Das Spiel läuft perfekt mit einem Ball, der springt und die Richtung mit einem Mausklick ändert, sowie seine Farbe. Allerdings möchte ich jetzt bestimmte Änderungen vornehmen, beispielsweise während das Spiel läuft. Ich möchte, dass die Größe des Balls klein ist und der Ball sich ausdehnt, während das Spiel gespielt wird. Ich habe meinen Code unten geteilt, was genau ich an diesem Punkt tun muss. Irgendwelche Vorschläge?Ändern der Größe eines Objekts in Action Script 3 Spiele
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends MovieClip {
private var ball:Ball = new Ball();
private var ballSpeed, cf: int;
private var isLeft, isUp, isLand: Boolean;
public function Main() {
// constructor code
createBall();
ballSpeed = 5;
isLeft = false;
isUp = false;
isLand = true;
cf = 1;
stage.addEventListener(Event.ENTER_FRAME, frameHandler);
stage.addEventListener(MouseEvent.CLICK, changeDirection);
}
private function changeDirection(m:MouseEvent){
if(isLand){
isLand = false;
} else {
isLand = true;
}
cf += 1;
if (cf > ball.totalFrames){
cf = 1;
}
ball.gotoAndStop(cf);
}
private function createBall(){
ball.x = stage.stageWidth * .5;
ball.y = stage.stageHeight * .5;
addChild(ball);
}
private function frameHandler(e:Event){
if(isLand){
if((ball.x + ball.width * .5) < stage.stageWidth && !isLeft) {
ball.x += ballSpeed;
}
if((ball.x + ball.width * .5) >=stage.stageWidth) {
isLeft = true;
}
if((ball.x - ball.height * .5) > 0 && isLeft) {
ball.x -= ballSpeed;
}
if((ball.x - ball.width * .5) <= 0){
isLeft = false;
}
}
if(!isLand){
if((ball.y + ball.height * .5) < stage.stageHeight && !isUp){
ball.y += ballSpeed;
}
if((ball.y + ball.height * .5) >= stage.stageHeight){
isUp = true;
}
if((ball.y - ball.height * .5) > 0 && isUp){
ball.y -= ballSpeed;
}
if((ball.y - ball.width * .5) <= 0){
isUp = false;
}
}
}
}
}