The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 5:36 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 1 post ] 
[Tutorial] Keys used Once Per Press 
Author Message
User avatar

Joined: Tue Aug 12, 2008 2:07 pm
Posts: 39
in this tutorial i'll show you how to make keys only be used once each time they are pressed
you can see an example in super smash bros

ex: hitting the jump or attack button and holding it will show the action only once and otherwise
stay in neutral

ok so what you should do first is to add a new var in your onClipEvent (load) { statement

Code:
onClipEvent (load) {
     sinJump = false
}


for my example i'm working with my jump key but you can do this for any key and you can name
it whatever you want it doesn't matter as long as you use the same name later

next in your if (Key.isDown("whatever your using it for"){
make sure that your doing this the right key.isDown if statement

Code:
if (Key.isDown("some key") && sinJump == false){
     sinJump = true;
}


what this is basically saying is when you press the key for the animation it checks to see if the
variable is false and if it is it will play the rest of the code

now for the part that allows you to actually be able to use the key again
make a new if statement
Code:
if (!Key.isDown("some key")) {
     sinJump = false;
}


and what this is telling flash is when you aren't pressing down the key to make the variable false
thus making keys only work once when pressed

i hope this helps

_________________
get free wii points here!


Sun May 30, 2010 7:49 am
Display posts from previous:  Sort by  
 [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.