Hi, I’m developing a game for my final year project at university that has a character who can move up and down on screen. The upper half of the screen is reflected in the lower half so that there are actually two characters on screen at once, each reacting exactly the same way to keyboard input.
One of the mechanics involves the two avatars changing positions relative to their halves of the screen which requires a spacebar press to execute. The problem I’m having is that I don’t want the characters to change positions once every frame if the spacebar is held down. I need to implement some sort of delay once the spacebar is pressed so that the characters won’t swap positions for another second or so.
Here is my project blog with the embeded swf files. At the moment they are just whitebox tests as I want to get the engine sorted before I drop in any of the art assets.
http://dsthompson.blogspot.com/
If anyone can help me out with this I’d really appreciate it. Here’s the code for the flip mechanic as it exists at the moment:
var plachaFlipPointY:Number = char.mc.y;
var shadowPlachaFlipPointY:Number = schar.mc.y;
if (placha.flip) {
placha.flip = false;
if (char.mc.y <= midPoint-3) {
char.mc.y = shadowPlachaFlipPointY;
schar.mc.y = plachaFlipPointY;
char.mc.scaleY = -1;
schar.mc.scaleY = -1;
}
else if (char.mc.y >= midPoint+3) {
char.mc.y = shadowPlachaFlipPointY;
schar.mc.y = plachaFlipPointY;
char.mc.scaleY = 1;
schar.mc.scaleY = 1;
}
}
(Please note, I have very little experience with actionscript and most of my code has been adapted from [FONT=Aachen-Bold][COLOR=#4d4d4d][FONT=Aachen-Bold][COLOR=#4d4d4d][COLOR=black]Gary Rosenzweig’s[/COLOR] [COLOR=black]Game Programming University book[/COLOR][COLOR=black].)[/COLOR]
[/COLOR][/FONT][/COLOR][/FONT]