Good morning everybody,
As usual poor the french woman has trouble well... (...)
I need .fla to understand this source BalloonPop.as and build the .fla :
Code: package {
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
public class BalloonPop extends MovieClip {
// display objects
private var balloons:Array;
private var cannonball:Cannonball;
private var cannonballDX, cannonballDY:Number;
// keys
private var leftArrow, rightArrow:Boolean;
// game properties
private var shotsUsed:int;
private var speed:Number;
private var gameLevel:int;
private const gravity:Number = .05;
public function startBalloonPop() {
gameLevel = 1;
shotsUsed = 0;
speed = 6;
gotoAndStop("level1");
}
public function startLevel() {
showGameScore();
// create object arrays
findBalloons();
// listen for keyboard
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
// look for collisions
addEventListener(Event.ENTER_FRAME,gameEvents);
}
public function findBalloons() {
balloons = new Array();
// loop through all display objects
for(var i:int=0;i<numChildren;i++) {
// check to see if the object is a Balloon
if (getChildAt(i) is Balloon) {
// if it is, then go to a random balloon color
MovieClip(getChildAt(i)).gotoAndStop(Math.floor(Math.random()*5)+1);
// add to our list of balloons
balloons.push(getChildAt(i));
}
}
}
public function gameEvents(event:Event) {
moveCannon();
moveCannonball();
checkForHits();
}
public function moveCannon() {
var newRotation = cannon.rotation;
if (leftArrow) {
newRotation -= 1;
}
if (rightArrow) {
newRotation += 1;
}
// check boundaries
if (newRotation < -90) newRotation = -90;
if (newRotation > -20) newRotation = -20;
// reposition
cannon.rotation = newRotation;
}
public function moveCannonball() {
// only move the cannonball if it exists
if (cannonball != null) {
// change position
cannonball.x += cannonballDX;
cannonball.y += cannonballDY;
// add pull of gravity
cannonballDY += gravity;
// see if the ball hit the ground
if (cannonball.y > 340) {
removeChild(cannonball);
cannonball = null;
}
}
}
// check for collisions
public function checkForHits() {
if (cannonball != null) {
// loop through all balloons
for (var i:int=balloons.length-1;i>=0;i--) {
// see if it is touching the cannonball
if (cannonball.hitTestObject(balloons[i])) {
balloons[i].gotoAndPlay("explode");
break;
}
}
}
}
// key pressed
public function keyDownFunction(event:KeyboardEvent) {
if (event.keyCode == 37) {
leftArrow = true;
} else if (event.keyCode == 39) {
rightArrow = true;
} else if (event.keyCode == 32) {
fireCannon();
}
}
// key lifted
public function keyUpFunction(event:KeyboardEvent) {
if (event.keyCode == 37) {
leftArrow = false;
} else if (event.keyCode == 39) {
rightArrow = false;
}
}
// cannonball launched
public function fireCannon() {
if (cannonball != null) return;
shotsUsed++;
showGameScore();
// create cannonball
cannonball = new Cannonball();
cannonball.x = cannon.x;
cannonball.y = cannon.y;
addChild(cannonball);
// move cannon and base above ball
addChild(cannon);
addChild(cannonbase);
// set direction for cannonball
cannonballDX = speed*Math.cos(2*Math.PI*cannon.rotation/360);
cannonballDY = speed*Math.sin(2*Math.PI*cannon.rotation/360);
}
// balloons call back to here to get removed
public function balloonDone(thisBalloon:MovieClip) {
// remove from screen
removeChild(thisBalloon);
// find in array and remove
for(var i:int=0;i<balloons.length;i++) {
if (balloons[i] == thisBalloon) {
balloons.splice(i,1);
break;
}
}
// see if all balloons are gone
if (balloons.length == 0) {
cleanUp();
if (gameLevel == 3) {
endGame();
} else {
endLevel();
}
}
}
// stop the game
public function cleanUp() {
// stop all events
stage.removeEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
stage.removeEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
removeEventListener(Event.ENTER_FRAME,gameEvents);
// remove the cannonball
if (cannonball != null) {
removeChild(cannonball);
cannonball = null;
}
// remove the cannon
removeChild(cannon);
removeChild(cannonbase);
}
public function endLevel() {
gotoAndStop("levelover");
}
public function endGame() {
gotoAndStop("gameover");
}
public function clickNextLevel(e:MouseEvent) {
gameLevel++;
gotoAndStop("level"+gameLevel);
}
public function showGameScore() {
showScore.text = String("Shots: "+shotsUsed);
}
My balloons seem so small too...
Somebody could me help to build my .fla ? please, please...
Thank's for your answers !
Tornada
France
Problem to build .fla with a source
Thursday, June 14, 2012
[Action Script] Problem to build .fla with a source June,2012
Posted by Bimo Hery Prabowo at 7:13 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment