timer is this by design

From the Asset Store
Tabata timer
$9.99 USD
Template for Tabata timer, fully documented in comments and video
  • Hi all,

    I have a simple project which contains only two instances of sprite object with timer behavior and two text objects, text1 and text2.

    dropbox.com/s/y5vyugjt9po0be6/timer_test.capx

    When the layout starts, each of the sprite's timer gets started.

    In the "on timer" event, each instance of the sprite object set the text property of a specific text object.

    But the second text object's text property is always intact since when the "on timer" event occurs C2 always pick the same instance of the sprite object.

    Is this by design?

    Thanks for any comment.

  • Since you are using the same tag, and both trigger at the same time, both are picked in On Timer. Add a For Each condition to On Timer, and each Sprite is then evaluated and it works as you expect.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I see.

    But I found even they don't start the timer at the same time, when "on timer" event is triggered, C2 still picks the same instance. You must add your own logic to check whose time is up.

    Is't it convenient to have each instance to have its own on timer event like "on destroy" or "on create" which references the instance who triggers the event?

    Tag maybe is a solution .But if you have many many instances, you must maintain so many "on timer" event even they all do the sam thing.

  • It's by design. 'On timer t' fires with both instances picked, because both their timers fired at the same time. Since the event 'i = 0' runs, the 'else' event does not run (else ignores picking of instances). If you replace 'else' with an inverted condition, it works fine.

  • Oh, I see, thanks.

    Is there any way to tell which instance starts the timer?

    dropbox.com/s/nhx8k8qjeuaak6n/timer_test2.capx

    In the project, no matter which instance start the timer (at different time with different tags),when the "on timer" event occurs, all instances get picked.

    Does the timer always treat the object's instances as a whole?

  • OK, now I understand I have to start the timer at different time or with different tag.

    Ashley, Thanks .

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