var ship:MovieClip=new Ship (); These lines tell flash to look in the Library for something
ship.x=275; called ship and places it in the co-ordinates listed.
ship.y=200;
addChild(ship);
import flash.events.Event;
import flash.events.KeyboardEvent;
var moveRight:Boolean = false These scripts tell flash to keep the commands off.
var moveLeft:Boolean = false
var moveUp:Boolean = false
var moveDown:Boolean = false
stage.addEventListener(Event.ENTER_FRAME, moveSquare)
function moveSquare(event:Event) {
if(moveRight==true) { all these commands tell flash to turn the commands on if the
square.x+=3; keys are being pressed down.
}
if(moveLeft==true) {
square.x-=3;
}
if(moveUp==true) {
square.y-=3;
}
if(moveDown==true) {
square.y+=3;
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN,pressKey);
stage.addEventListener(KeyboardEvent.KEY_UP,stopSquare);
function stopSquare(myevent:KeyboardEvent):void{ These codes are turning off the command
moveLeft=false when the buttons arent pressed.
moveRight=false
moveUp=false
moveDown=false
}
function pressKey(myevent:KeyboardEvent):void{
if(myevent.keyCode==Keyboard.RIGHT){
moveRight=true;
}
if(myevent.keyCode==Keyboard.LEFT){
moveLeft=true;
}
if(myevent.keyCode==Keyboard.UP){
moveUp=true;
}
if(myevent.keyCode==Keyboard.DOWN){
moveDown=true;
}
}
Feedback from blog check:
ReplyDelete1)Very good research into Asteroid games, great to see that you have already added pictures!
2)Good start to thinking about the design of your game. I do like your background and icon designs (looking forward to seeing more soon).
3) Your report was a very enjoyable read for me, and as we discussed adding in about the compiler, accessing URL's and also about the use of folders and colour coding, as this would help add more information to your report. Great overall summary to finish.