Switch focus of Touch

Get help using Construct 2

Post » Sat Jun 08, 2013 9:44 pm

How would you go about switching the touch focus from one object to another?

I'm building a circus based game where a clown is being shot out of a cannon. I got the shooting out of the cannon bit working, based on the first touch (click of mouse).

Now that the clown is airborne, I want to focus the touch action so everytime the player touches the screen, the clown will flap his hands and give him some "lift", based on a set amount of points. Every touch will decrease those points, until none is left and the clown crashes on the ground.

At the moment, whenever the touch option is enabled, a new clown get's generated and shot out of the cannon.

I've tried using "on Nth touch" but I don't think I'm getting it right.
Also, in order to keep things neat, how would you use Groups for this?
I'm thinking of using one Group for the cannon function, and one Group for the clown flying function.

Any ideas on how to solve this?

Cheers.
B
19
S
5
G
6
Posts: 32
Reputation: 4,194

Post » Sat Jun 08, 2013 9:51 pm

I'd say it's as simple as creating a local boolean variable, something like isFlying; set isFlying to true when you launch the clown, and only run the clown launching event if isFlying = false.

Or just do what you thought of doing: use groups. Just disable the cannon launching one as soon as the clown is in the air.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Sat Jun 08, 2013 10:04 pm

@geometriX: I've tried doing that with the variable, but I think I'm getting a bit lost in translation.

I'm attaching the capx.

cannon test

Any ideas? Thanks.
B
19
S
5
G
6
Posts: 32
Reputation: 4,194

Post » Sat Jun 08, 2013 10:23 pm

I removed the group disabling/enabling stuff. It's much quicker to just test the isFlying condition on touch.

Updated capx (r133). I've made a few changes but have commented wherever I've done so.
GeometriX2013-06-08 22:24:12
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Sat Jun 08, 2013 10:45 pm

Thank you so much @GeometriX!
I owe you a beer.

Cheers.
B
19
S
5
G
6
Posts: 32
Reputation: 4,194

Post » Sat Jun 08, 2013 11:18 pm

Sweet, my pleasure. Good luck with your game.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 44 guests