0 Favourites

On Finger Being Held Down On An Object + Timer

  • I am relatively new to Construct 2, so bare with me if this is a simple problem I am trying to solve here.

    I am essentially creating a game where you hold your finger down on the screen (on a particular object which is a button) and a timer counts down from 3 before the game starts. If you lift your finger before the timer is finished, the timer resets and the game doesn't start.

    For reference I am using the wonderful TimeManager plugin for Construct 2 for the countdown functionality.

    Pseudo-code for reference:

    While finger is being held down and touching object {

        Timer counts down from 3 seconds

    }

    If (finger is lifted off of the object before the timer reaches zero) {

        Stop timer counting and reset to 3 seconds

    }

    What is the best way I can achieve such a thing? Are while loops able to support multiple events? The syntax isn't all what I am used too compared to other languages like Javascript or PHP.

  • One way you could do this is this: (I am referencing a mouse object)

    Create a small object and every tick change its location to that of the cursor.

    if(left button is down or finger is down)

        If small object is overlapping button object

            add dt to some timer variable

            If timer variable >= to some time (3 seconds)then start game

        Else set timer variable to 0

    On left button or finger released set timer variable to 0

    The syntax is actually very similar to programming in anything else (I do c#, vb, c++)

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • give the object timer behaviour,

    on object touched

    -- start timer

    on any touch end

    is touching object

    -- stop timer

    on timer

    is touching object

    -- start

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