Creates
a string variable that is empty and has no value
var
gameState:String;
//*********BEGINNING STUFF**************/
Means that that the movie clip endScreen is false (i.e. invisible)
Means that that the movie clip endScreen is false (i.e. invisible)
endScreen.visible
= false;
//**************INTRO
SCREEN**************/
Making the
child of the movieclip introScreen a button that is clickable
Looks for the
function click away ( this is done with open+closed brackets)
It calls the
function to move the movie clip out of the screen to reveal game screen
Also sizes the
screen and drags it the x axis and takes the image out of the screen (screen x=
(screen.wdith*-1;) (-1 is left and +1 is right)
Gamestate is a
variable and in the variable you are putting in INITGAME which shows the value
and state of the variable.
AddEventListner
means its listening out for the even Enter_FRAME, game loop, meaning it will
listen out for a new enterframe event and until then loop the screen.
introScreen.play_btn.addEventListener
(MouseEvent.CLICK, clickAway);
function
clickAway (event:MouseEvent):void {
moveScreenOff (introScreen);
}
function
moveScreenOff (screen:MovieClip):void {
screen.x = (screen.width)*-1;
gameState = "INITGAME";
addEventListener (Event.ENTER_FRAME,
gameLoop);
}
//**************GAME
STATES**************/
function
gameLoop (e:Event):void {
switch (gameState) {
case "INITGAME":
initGame();
break;
case "STARTPLAYER":
startPlayer ();
break;
case "PLAYGAME" :
playGame ();
break;
case "ENDGAME" :
endGame ();
break;
}
}
//**************STATE_INIT_GAME**************/
Trace when you
run the movie will be printed out on an out movie in flash.
function initGame ():void {
trace("add stuff to
initGame")
gameState
= "STARTPLAYER";
}
//**************STATE_START_PLAYER**************/
function
startPlayer ():void {
trace("add
player stuff")
gameState = "PLAYGAME";
//**************STATE_PLAY_GAME**************/
Makes play game
a function along with calling on with the 2 smaller ones,
And then makes the clipboard memory remember
Endgame
function
playGame ():void {
makeEnemies ();
testForEnd ();
}
function
makeEnemies ():void {
}
function testForEnd ():void {
gameState
= "ENDGAME";
}
/**************STATE
ENDGAME**************/
function
endGame ():void {
removeGame ();
endScreen.visible = true;
removeEventListener (Event.ENTER_FRAME,
gameLoop);
showResults ();
}
Creates a function called showResults
With the child button
Creating a click event (clickFinalAway)
Calls a function shows results
function
showResults ():void {
trace ("Show Results");
endScreen.play_btn.addEventListener
(MouseEvent.CLICK, clickFinalAway);
function clickFinalAway
(event:MouseEvent):void {
trace ("clickFinalAway");
moveScreenOff (endScreen);
}
}
//**************REMOVE
GAME**************/
function
removeGame ():void {
}
>imputed all script
>added movie clips (endscreen + start screen)
>animated start screen
>fixed bugs
>made buttons play_btn
> This allowed the loop actionscript to work
>animated start screen
>fixed bugs
>made buttons play_btn
> This allowed the loop actionscript to work
Screen grabs of working Script.
"tempEnemy.speed = 2;" and then you put an 'if' statement and then you can do the same for the second and make the number higher to make it go faster.






No comments:
Post a Comment