On Finger Being Held Down On An Object + Timer

Get help using Construct 2

Post » Thu Feb 13, 2014 5:39 am

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.
Posts: 44
Reputation: 538

Post » Thu Feb 13, 2014 6:12 am

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++)
Posts: 566
Reputation: 5,282

Post » Thu Feb 13, 2014 7:45 am

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
Posts: 6,160
Reputation: 19,775

Return to How do I....?

Who is online

Users browsing this forum: FishInABucket, kelany, plinkie and 4 guests