How do I detect simultaneous gamepad inputs ?

Get help using Construct 2

Post » Fri Oct 13, 2017 10:54 am

@Dop2000
Oh ! I love your system, the use of the For Loop and the Dictionary, much more compact !

There's a slight difference with my previous system : when a button is pressed, I start "holding" on the same frame it is pressed, when you only start "holding" one frame later since you can't have PRESSED and HOLD at the same time in the Dictionary.
That said, I'll probably adapt your system a bit and use it, it is much less tedious to write so I can more easily add more buttons :D

Also, I love these kinds of expressions :
Set Keyname to loopindex=0 ? "A" : loopindex=1 ? "B" : loopindex=2 ? "X" : "Y"

What's the name of this advanced way of writing ? Is it Java ? If so I need to give it a shot, it's very convenient.
(isn't it missing a "loopindex = 3 ?" before the "Y" ? Maybe there's a difference because it is the last one)

Thanks a bunch \o/
B
6
Posts: 38
Reputation: 337

Post » Fri Oct 13, 2017 11:27 am

Glad to help!

(loopindex=0 ? "A" : "Z") means if loopindex=0 then "A", otherwise "Z".
It's called ternary operator, I think it exists in many languages.
You can nest them one inside another, and yes "Y" at the end basically means "anything else". You can change it to this:
Set Keyname to loopindex=0 ? "A" : loopindex=1 ? "B" : loopindex=2 ? "X" : loopindex=3 ? "Y" : "other"

Of course if you have 20 buttons, this expression will become quite long and messy.
You may use a different method, for example pick name from a string like this "A,B,X,Y,,,DpadUp,DpadDn,....." using TokenAt(KeyNames, loopindex, ",").
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
71
Posts: 1,085
Reputation: 38,733

Previous

Return to How do I....?

Who is online

Users browsing this forum: max2612, Yahoo [Bot], Zzarkz and 22 guests