Switch focus of Touch

0 favourites
  • 6 posts
From the Asset Store
A game template with a great amount of assets! You will be able to create a full game just with the assets provided!
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

  • Thank you so much GeometriX!

    I owe you a beer.

    Cheers.

  • Sweet, my pleasure. Good luck with your game.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)