Page 1 of 1

Key up

PostPosted: Thu Jan 24, 2008 5:53 pm
by Azou
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:

Re: Key up

PostPosted: Thu Jan 24, 2008 5:55 pm
by Kalladdolf
you wanna make the player attack when you press the button?
or when you let it go?

Re: Key up

PostPosted: Thu Jan 24, 2008 7:10 pm
by Azou
When i let it go :P

Re: Key up

PostPosted: Mon Jan 28, 2008 8:30 am
by Kalladdolf
sounds weird, can u post an example?
I still don't get it...

Re: Key up

PostPosted: Mon Jan 28, 2008 12:53 pm
by Bee-Ant
Just move the codes in Keydown event to Keyup event...sooo simple...

Re: Key up

PostPosted: Tue Jan 29, 2008 10:24 am
by Kalladdolf
:|
I don't think he means that, maybe some sorta mixture???
:?

Re: Key up

PostPosted: Wed Jan 30, 2008 8:37 pm
by DarkParadox
i helped him solve this problem in the chat box, you no longer have to worry.

Re: Key up

PostPosted: Sat Feb 09, 2008 4:16 pm
by thunderios
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?

Re: Key up

PostPosted: Sun Feb 10, 2008 4:17 am
by Bee-Ant
I think...Btw, I have a code to make that charge system :D

Re: Key up

PostPosted: Sun Feb 10, 2008 4:33 am
by edh
diormeh wrote:i helped him solve this problem in the chat box, you no longer have to worry.


@diormesh : what was the solution?

Re: Key up

PostPosted: Mon Feb 11, 2008 6:28 am
by DarkParadox
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
}

Re: Key up

PostPosted: Mon Feb 11, 2008 8:59 am
by Bee-Ant
Good work di

Re: Key up

PostPosted: Mon Feb 11, 2008 10:34 am
by DilloDude
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.