(REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-04 11:13:01
im using actionscript 2.0, in flash 8, so can anyone help me?
(REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-04 11:13:01
im using actionscript 2.0, in flash 8, so can anyone help me?
Response to (REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-04 17:00:33 (edited 2023-08-04 17:02:58)
At 8/4/23 11:13 AM, SuperGibaLogan wrote: im using actionscript 2.0, in flash 8, so can anyone help me?
Use the keyUp clip event or listener if you want it to be triggered only once.
onClipEvent(keyUp) { trace(Key.getCode()) }
But if you want it to be triggered only once and when it is pressed (not released), then set a boolean to true when it is pressed.
onClipEvent(load) { this._key_pressed = false } onClipEvent(keyDown) { if (this._key_pressed == false) { trace('key pressed: ' + Key.getCode()) this._key_pressed = true } } onClipEvent(keyUp) { this._key_pressed = false }
Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp
"Sit look rub panda" - Alan Davies
Response to (REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-04 17:03:01
thanks, but how do i use it in a script tho?
Response to (REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-04 17:10:37 (edited 2023-08-04 17:11:51)
also, can you please send me a full script like this, but with the script you replied with? to make my character move forever when a key is only pressed?
here is the script:
onClipEvent(enterFrame) {
if(Key.isDown(Key.LEFT)) {
this._x -=5;
}
if(Key.isDown(Key.RIGHT)) {
this._x +=5;
}
if(Key.isDown(Key.UP)) {
this._y -=5;
}
if(Key.isDown(Key.DOWN)) {
this._y +=5;
}
}
just replace the "this._x +=5;" or "this._y +=5;" parts with your script, thanks!
Response to (REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-04 22:49:33
At 8/4/23 05:03 PM, SuperGibaLogan wrote: thanks, but how do i use it in a script tho?
You can create a variable like "_X_key_pressed" for each key you want to have pressed, or use an Object to store those details - and then use an IF condition to check whether those keys have been pressed or not.
At 8/4/23 05:10 PM, SuperGibaLogan wrote: also, can you please send me a full script like this, but with the script you replied with? to make my character move forever when a key is only pressed?
Two things:
Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp
"Sit look rub panda" - Alan Davies
Response to (REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-11 14:11:49
At 8/4/23 11:13 AM, SuperGibaLogan wrote: im using actionscript 2.0, in flash 8, so can anyone help me?
can someone also tell how to do this but in construct 2?
Response to (REPOST) how do i make a character move when a key is pressed but not holding the key? 2023-08-15 15:43:05
alright, thanks