Key up

Non-platform specific questions.

Key up

Postby Azou » Thu Jan 24, 2008 5:53 pm

Konichiwa,everybody! :D
Well,i've got a problem:I'm making and attack with key up function ( for example down and keypad 6. The key up function is for down button)
But,the problem is that we can directly push and hold down button,after that,the attack will work!!
How can i repair this? :cry:
User avatar
Azou
 
Posts: 514
Joined: Thu Sep 13, 2007 1:12 pm
Score: 35 Give a positive score

Re: Key up

Postby Kalladdolf » Thu Jan 24, 2008 5:55 pm

you wanna make the player attack when you press the button?
or when you let it go?
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Key up

Postby Azou » Thu Jan 24, 2008 7:10 pm

When i let it go :P
User avatar
Azou
 
Posts: 514
Joined: Thu Sep 13, 2007 1:12 pm
Score: 35 Give a positive score

Re: Key up

Postby Kalladdolf » Mon Jan 28, 2008 8:30 am

sounds weird, can u post an example?
I still don't get it...
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Key up

Postby Bee-Ant » Mon Jan 28, 2008 12:53 pm

Just move the codes in Keydown event to Keyup event...sooo simple...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Key up

Postby Kalladdolf » Tue Jan 29, 2008 10:24 am

:|
I don't think he means that, maybe some sorta mixture???
:?
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Key up

Postby DarkParadox » Wed Jan 30, 2008 8:37 pm

i helped him solve this problem in the chat box, you no longer have to worry.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Key up

Postby thunderios » Sat Feb 09, 2008 4:16 pm

If u attack at the moment you release the button, you might have a charge-system, for every x ms u charge you do 1 more damage or something...
That's where its for, isn't it?
thunderios
 
Posts: 87
Joined: Thu Jan 31, 2008 1:18 pm
Score: 1 Give a positive score

Re: Key up

Postby Bee-Ant » Sun Feb 10, 2008 4:17 am

I think...Btw, I have a code to make that charge system :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Key up

Postby edh » Sun Feb 10, 2008 4:33 am

diormeh wrote:i helped him solve this problem in the chat box, you no longer have to worry.


@diormesh : what was the solution?
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: Key up

Postby DarkParadox » Mon Feb 11, 2008 6:28 am

Create a Timer at your length, he used 1000 miliseconds(1 second)lets name it chargeTM.
MUST BE A REPEAT FOREVER TIMER
on key down>your button>create timer(chargeTM).
on timer event>chargeTM>script editor:
Code: Select all
charge_var ++; //use any variable(you must create it)
attack_power ++; //use any variable(you must create it)
if(charge_var == max number)//put the max amount of times you want to repeat this timer(max number)
{
your actions here
charge_var = 0;//use the variable you used here(charge_var ++;)
DestroyTimer("chargeTM");//don't erase
}
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Key up

Postby Bee-Ant » Mon Feb 11, 2008 8:59 am

Good work di
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Key up

Postby DilloDude » Mon Feb 11, 2008 10:34 am

Using timers like that would work. I generally prefer variable counters (the last time I used a timer was yonks ago). What i'd do is something along the lines of this:
Code: Select all
//on keyDown event
//use whatever statements to check attackability, then
charging = 1;
power = 0;

//drawActor event
if (charging)
{
    power ++;
    if (power >= 90)//30 * the number of seconds
    {
        //peform some action to use maximum power
    }
}

//on keyUp event
if (charging)
{
    //peform some action based on power
    power = 0;
    charging = 0;
}

Obviously you'd want some way of storing what attack you were charging, and maybe vary the max charge time with a variable. That's just a basic concept framework, so you'd want to customize it a lot.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron