Okay i am currently a student in a Game Design and Simulation program at New England Tech. I am completely new to actionscript and i am trying to get a good grasp as to what is going on.
So i got together with a bunch of friends and we decided we want to make a 2d JRPG-esc game. After much deliberation we also decided on Flash to be our engine. (Which is awesome because i need the actionscript practice).
Me getting to the point :
I am trying to flesh out the basic mechanics of the game before i get into a lot of the artwork. I figure it will be easier to code/learn now, rather than postpone it further.
I have movement down(W A S D keys), and i have collision down (a movieClip exported for actionscript and grabbing the Wall.as)
The next feature i’d like to implement would be a pause menu that will pop up on the stage when the player hits “Enter”
Examples of this:
I know the exact coordinates i want this menu to pop up on the stage from the library ( x = 707.5 y = 299 ) My Stage is 800 x 600 px
Current Code in the game.fla:
stop();
//declare speed and direction variables
var speed:Number;
//direction x and y variables
var dirX:String;
var dirY:String;
//assign speed variable
speed = 10;
//add eventlisteners to the stage
stage.addEventListener(KeyboardEvent.KEY_DOWN, movement);
stage.addEventListener(KeyboardEvent.KEY_UP, idle);
stage.addEventListener(Event.ENTER_FRAME, main);
//create function for checking movement direction
function main(e:Event):void{
//add or subtract from player's x coord
switch (dirX) {
case "left":
player.x -= speed;
break;
case "right":
player.x += speed;
break;
case "idle":
player.y += 0;
break;
}
//add or subtract from player's x coord
switch (dirY) {
case "up":
player.y -= speed;
break;
case "down":
player.y += speed;
break;
case "idle":
player.y += 0;
break;
}
}
//create function for setting direction variables on key down
function movement(e:KeyboardEvent):void {
if(e.keyCode == 65){
dirX = "left";
} else
if(e.keyCode == 68){
dirX = "right";
}
if(e.keyCode == 87){
dirY = "up";
} else
if(e.keyCode == 83){
dirY ="down";
}
}
//create function for setting direction variable on key up
function idle(e:KeyboardEvent):void {
if(e.keyCode == 65){
dirX = "idle";
} else
if(e.keyCode == 68){
dirX = "idle";
}
if(e.keyCode == 87){
dirY = "idle";
}else
if(e.keyCode == 83){
dirY ="idle";
}
}
If someone could please just explain in simplest terms. That’d be great… :-/