How do I get this simple timer test to work?

Get help using Construct 2

Post » Thu Dec 26, 2013 8:07 pm

I have a Sprite object type with a Timer behavior.

There are three instances of this Sprite on the Layout.

In the EventSheet on start up I loop through all Sprite objects and for each Sprite I start the timer with the Tag set to an instance variable on each Sprite.

There is an event listening for the Timer event for each Tag (set with the Instance Variable again) and if you look at the browser console you can see only one of them is fired.

Here is a capx (http://sdrv.ms/1bsA3LH)
B
21
S
5
Posts: 196
Reputation: 1,984

Post » Thu Dec 26, 2013 8:46 pm

try changing the start timer to 3 different values

(eg

start timer sprite.TimerName (random(5)) (once)

)

and see if you get an output more like you are expecting ?



RamPackWobble2013-12-26 20:47:32
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Thu Dec 26, 2013 8:48 pm

Why did that work?

Is it just not possible to have sprites sharing the same timer interval?
B
21
S
5
Posts: 196
Reputation: 1,984

Post » Thu Dec 26, 2013 9:06 pm

ok change it back to just 1.

add a sub event under your on timer sprite.timername
and check each sprite that has fired its timer

sprite   -   on timer sprite.timername
(sub event)
   for each sprite      -    send info to console
                             ( log in console : etc)



RamPackWobble2013-12-26 21:09:18
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Thu Dec 26, 2013 11:29 pm

Thanks much.

I think they are packing all events for each sprite together into a single event since they are of the same type and are occurring at the same time.
B
21
S
5
Posts: 196
Reputation: 1,984

Post » Fri Dec 27, 2013 12:59 am

You need to reverse RomPackWobbles events:
For each Sprite
   On Timer...

The issue is that your original On Timer has all Sprites picked at the same time, so the event only gets triggered once. The for-loop checks each individually. The down side is that the for-loop will run constantly, forever.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests