How do I prevent click through

Get help using Construct 2

Post » Fri Aug 12, 2016 9:05 am

With a state machine you can jump to any portion of the sate machine you want.

Using my dirty-example above all you need to do is have a couple of extra conditions on the state change like;

[On Touch]
[Room1State=0]
--- Activate room

[On Touch]
[Room1State=1]
[Touch is on power-up object]
--- Collect Power-up
--- Set Room1State to 0
[ELSE]
--- Set Room1State to 0

I guess my pseudo code isn't exactly accurate to your specific circumstance, but it would be the method that I would use if I were trying to achieve what you're trying to build.

Basically by having a state machine - and comparing the touch position (is it within X distance to the powerup) you can control which "thing" the player is actually touching on. You may also find this can be solved by making the bounding collision box of your power-ups larger - because from memory, it shouldn't "click through" anyway - but it's been a million years since I've made anything for a touch device (so I wouldn't go by my terrible memory of things).

Think of the state/gate system as a fail-safe. If the power-up exists in a room then the state is 1... but if the player presses on the room and the power-up coordinates are far away from the touch position, then set state to 0 and the player is activating the room itself, otherwise it stays as 1 and collects the power-up then goes to 0.

I hope this makes it a little clearer.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Fri Aug 12, 2016 9:18 am

On touch "Room"
.. Sub event "Is touching PowerUP"
.. ... Actions regarding the PowerUP, not considering to activate the room.
.. Sub event Else, "Is not touching PowerUP"
.. ... Actions to activate the room without dealing with the power up at all.

Simplest way to handle it with the plugin Touch I think.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,310
Reputation: 71,084

Post » Fri Aug 12, 2016 2:05 pm

Thanks guys! I'll give it a go :)
B
6
S
1
Posts: 19
Reputation: 440

Post » Sun Aug 21, 2016 7:11 am

Hey cornfl4ke, :)

edit: I just noticed that I hadn't seen that there was a page 2 for this post with some existing answers. Well here's another then... :)

If I understand correctly, it sounds like you want to arrange for the following:

1. A player can always pick up an item by tapping it.
2. A single tap that picks up an item won't activate a room.
3. If an item is sitting somewhere on a room , the player should be able to tap anywhere else on that room to activate the room without picking up the item.

Just to clarify #3, given a room with an item sitting on the northern half, a player should be able to tap the southern half of the room to activate the room without "touching" the item.

So, when the user taps,
you first check if the tap was on an item, and if it was, you then run the item pickup actions.
Or ELSE, (if the tap was NOT on an item),
then check if the tap was on a room, and if it was, you then run the room activation actions.

The events would look like this.

  • - On touch:
    • - Is touching object (item):
      • (Place the actions for touching an item here.)
    • - ELSE
      - Is touching object (room):
      • (Place the actions for touching a room here.)

Note that the "ELSE" and the "Is touching object (room)", are two conditions together in the same event.
To create an "ELSE" condition, select an event and press X to create an ELSE below it.
Or, right click an event (a whole event not just a condition) and choose Add > Add Else.

Hope that helps out. :)
B
27
S
18
G
8
Posts: 331
Reputation: 6,164

Post » Sun Aug 21, 2016 10:38 am

Just use 'else', thats why it is for.

New top-level event ...
Condition > on powerup clocked
.....................do all the stuff you need

New top-level event ...
Condition > on house clicked
.....................do all the stuff you need


For me (personal) this a bit of a PITA. I have troubles reading this code and they need to stay a pair when i start moving events arround. So i usaly do ...

New EMPTY top-level event
....Sub event with the conditions ...
....Condition > on powerup clocked
.....................do all the stuff you need

....Sub event with the conditions ...
....Condition > on house clicked
.....................do all the stuff you need
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Aug 21, 2016 7:49 pm

This is gonna get clustered if you use too many same button press for two or three different same spot why not do something like use two different button or is this going to be mobile ?
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Previous

Return to How do I....?

Who is online

Users browsing this forum: Felipiwi and 18 guests