I'm making a game on flash (you would be wondering why I have flash pro 8) and I need some help making the code to make it do the following: slide when moving, gravity, cpu moving and when to do the attacks.
I'm only a beginner at flash, although I got it 4 weeks ago.
Please give the code for it and I can show a picture I made in flash for every code posted.
Offline
moving:
onClipEvent (load) {
xSpeed = 0;
ySpeed = 0;
}
onClipEvent (enterFrame) {
xSpeed *= 0.8; //change 0.8 to your prefference, higher slower stop lower faster stop
ySpeed += 0.8;
_x += xSpeed;
_y += ySpeed;
if (Key.isDown(Key.RIGHT)) {
xSpeed += 5;
}
if (Key.isDown(Key.LEFT)) {
xSpeed -= 5;
}
if (Key.isDown(Key.UP)) {
ySpeed -= 5;
}
if (Key.isDown(Key.DOWN)) {
ySpeed += 5;
}
}Last edited by terminator355 (2009-01-01 20:04:50)
join me for some Black Ops on xbox: termhn or for some rock band on PS3: rocket232Offline
Here's how to do key press events (I think)
keyListener:Object=new Object
keyListener.onKeyDown=function(){
keyPressed=String.fromCharCode(Key.getAscii());
testKey="z"
//the testKey variable is the key that activates a function
if(keyPressed==testKey){
doSomething();
}
}
Key.addEventListener(keyListener)For keys like the arrows and spacebar, you can ignore the eventListener garbage and simply use:
if(Key.isDown(Key.SPACE)){
doSomething():
}Finally, you might consider adding a hidden button that responds to key press events.
Hope this helps!

Offline