on button released equivalent to analog stick

Get help using Construct 2

Post » Fri Oct 18, 2013 5:15 pm

i am stuck in an event like this
if overlapping"that" and
right key is pressed   then set true

if overlapping"that" and
right key is released   then set false

now i add this
if overlapping"that" and
right key is pressed or gamepad compare x>90
then set true
what is the reverse for the stick?
if i add gamepad compare x <90 or compare x=0(for me to go to center)
it just wont work. i also have the same for left so maybe it is looping
non stop. with the pressed and released actions it works.
thank you all!
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Fri Oct 18, 2013 7:18 pm

Since it's an analog control there is no on released. One way around this would be to use a global variable for each control with the values of 0 for up and 1 for down. Every tick set all controls to up or 0 then check the keyboard, gamepad or any other control scheme you use and set the relevant control to 1 or down. Be sure this is at the top of the event sheet. Then you can reference the variables elsewhere in your events to see the control state. This will make your events more readable and it will make it trivial to add more control types.

global number control_left = 0
global number control_right = 0
...

Every tick:
--- set control_left to 0
--- set control_right to 0
--- ...

key left pressed
or
gamepad compare x<-90
--- set control_left to 1
...R0J0hound2013-10-18 19:19:01
B
92
S
32
G
110
Posts: 5,298
Reputation: 71,507


Return to How do I....?

Who is online

Users browsing this forum: batto, dop2000, Magistross and 24 guests