GDevelop-extensions icon indicating copy to clipboard operation
GDevelop-extensions copied to clipboard

New Extension: Key Press

Open TheGemDev opened this issue 2 years ago • 14 comments

An extension that checks how many times a keyboard key was pressed in a period of time ( maximum delay ), works just like the double click extension but for keyboard keys.

image

TheGemDev avatar Aug 28 '23 20:08 TheGemDev

Does this also have a function to detect how long a key has been depressed? (for charging spells/attacks)

Condition: "Button X has been pressed for Y seconds"

I also wonder if it should have an expression that shows the percent complete?

Action: Start an X second long charge named "SuperAttack"

Expression: ChargePercent("SuperAttack")

Condition: "SuperAttack" is charging Condition: "SuperAttack" is fully charged

Action: Cancel charging "SuperAttack" (the user can use this for key released, or perhaps if the player gets hit while charging)

tristanbob avatar Aug 28 '23 20:08 tristanbob

Just commenting to say that this is a great idea and should simplify the work of many people if this can be flexible enough 👍

4ian avatar Aug 28 '23 20:08 4ian

Does this also have a function to detect how long a key has been depressed? (for charging spells/attacks)

Condition: "Button X has been pressed for Y seconds"

I also wonder if it should have an expression that shows the percent complete?

Action: Start an X second long charge named "SuperAttack"

Expression: ChargePercent("SuperAttack")

Condition: "SuperAttack" is charging Condition: "SuperAttack" is fully charged

Action: Cancel charging "SuperAttack" (the user can use this for key released, or perhaps if the player gets hit while charging)

Sure, i can try adding a feature like that.

TheGemDev avatar Aug 28 '23 20:08 TheGemDev

this works

image

TheGemDev avatar Aug 28 '23 21:08 TheGemDev

I was wondering what data type is required here?. the parameter type is a "keyboard key", but typing the key as a string doesn't seem to work.

image

TheGemDev avatar Aug 28 '23 22:08 TheGemDev

I was wondering what data type is required here?. the parameter type is a "keyboard key", but typing the key as a string doesn't seem to work.

The screenshot doesn't show the action sentence. I don't have enough context to answer.

D8H avatar Aug 29 '23 08:08 D8H

Okay, I need to take a look at the extension again, I will send an update later in the day.

TheGemDev avatar Sep 03 '23 14:09 TheGemDev

Okay, I need to take a look at the extension again, I will send an update later in the day.

Do you want to work on this more? It is probably close to being merged when you are ready.

tristanbob avatar Oct 06 '23 21:10 tristanbob

yes, i will still work on it.

gemmomoh avatar Oct 11 '23 16:10 gemmomoh

@D8H This was my question, in order to get the key pressed duration I need to get the key user is checking for I used this image image

the parameter type is a keyboard key image

but it still returns an error.

gemmomoh avatar Oct 13 '23 06:10 gemmomoh

@D8H This was my question, in order to get the key pressed duration I need to get the key user is checking for I used this

the parameter type is a keyboard key

but it still returns an error.

It's really hard to follow with the events being cut. This parameter type don't accept an expression. If you need call private actions use a text parameter.

D8H avatar Oct 13 '23 12:10 D8H

okay

gemmomoh avatar Oct 13 '23 14:10 gemmomoh

image

TheGemDev avatar Oct 13 '23 15:10 TheGemDev

oh, ok, I guess the key parameter type can't be used for expression parameter. The UI should probably not show it in the list in this case.

D8H avatar Oct 13 '23 16:10 D8H