Request - Instanced Trigger Once

Discussion and feedback on Construct 2

Post » Tue Jul 01, 2014 7:51 pm

Over the past couple days, I've been playing around with a new game. I've found some interesting things that I didn't know about before; mainly Trigger Once. I've always had issues in the past using this with multiple instances, but have finally realized that if 2 instances do something at the same exact time, because the trigger once is global it will generally break the event.

So my request, or rather inquiry, is this; is there a way to get a "trigger once" for a sprite event instead of a system event? I know you can do something like this to create a proper trigger once per instance:

If InstanceVar = 0
Do something and Set InstanceVar to 1

This will always work, but it requires more lines of code, instance variables, and can certainly certain complicate code that is much more complex.

I'm imagining "For Each" is a solution, but everytime I try and use it, it never works like I want it to.

I'm curious of everyone else's thought on this.
B
43
S
12
G
1
Posts: 545
Reputation: 4,246

Post » Tue Jul 01, 2014 7:59 pm

Would most certainly use this feature a lot.
B
51
S
20
G
10
Posts: 571
Reputation: 9,819

Post » Tue Jul 01, 2014 8:53 pm

Yea, but how would it pick a specific instance from the top tier?
As with all picking, just saying object do foo, makes all, or just the first instance do it.
So basically its the same either way, an extra condition, or an extra action.
Image ImageImage
B
171
S
50
G
180
Posts: 8,395
Reputation: 113,984

Post » Tue Jul 01, 2014 9:59 pm

@newt - If I understand what you're saying, it wouldn't actually need to pick an instance. It would just be nice to say "run this action ONCE while the event above is true" without having complications from multiple instances of 1 object running the same event. Setting an instance variable as a "trigger once" creates the problem of "Ok, now it = 1 so it will only trigger once while it is 0 ... where do I set it back to 0, and when?"

It's not so much a feature as it is a time saver :P
B
43
S
12
G
1
Posts: 545
Reputation: 4,246

Post » Wed Jul 02, 2014 2:59 am

Why not either do this On Object Created and/or On Startup Layout.

If you do it on startup for created objects in the layout then it's done on start up(only once)
For the objects created during play. Then it's on Create so only triggered once.
If it's triggered under other criteria to do this. Then wouldn't that be criteria specific?
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038


Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests