How do I prevent variable checks on too many instances?

Get help using Construct 2

Post » Thu Jun 30, 2016 6:03 am

@Unconnected

It would really help if you posted a sample capx file and let us make some suggestions.

You had trouble finding a loop with Wait built in because you can not slow down a loop. That is not what Wait does.
The code on an event sheet runs really fast - 60 times every second. And the code can execute thousands of commands every tick without any trouble.

Wait defers the code immediately after it, but the event sheet continues to run at the same speed (blazingly fast). That is why GroupFrame was getting to 25 so fast - before you can even blink.

I get the feeling you are making this more complex than it needs to be. You seem concerned about having to do too many variable checks, but Construct2 can easily check 624 objects per tick. The problem may be that it does it too fast. That is why you have to structure things in entirely different ways to slow things down.
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Thu Jun 30, 2016 6:09 am

if you want to add 1 to GroupFrame every 0.5 seconds, you dont need to create a loop, and slow the loop down...

you just create an event: Every 0.5 Seconds, with an action: Add 1 to GroupFrame

(The event sheet as a whole is already a loop... you don't need to put a command like that inside another loop.)
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Thu Jun 30, 2016 6:29 am

You can have wait in loops. I have seen a few examples and I even had a few example Capx that worked with wait in a loop. You just have to do is add:

"wait '1*loopindex' seconds"

Into the loop. It seems to work for every loop except for what I was trying to do. I can only assume I had something structured wrong.

I have a lot of complicated groups in the capx to make things appear in certain ways and it is a project I have been working on for a long time. I don't want to just make my project Public Domain by adding it online. I have a ton of my own art and my own sounds etc in it. I can't just copy a few groups or events out into a new capx, because it is intertwined rather well. I suppose I could post a photo, but then I would have to explain every Variable. I will admit sometimes I will over complicate something, but I always come up with a more simple solution, or someone points it out. I may have an extra unneeded variable here and there that isn't needed, but all groups and functions are done rather simply and function very well.

I found it would be better to ask for an example or a solution to a problem. I was having an 'expression' issue, mostly because I am still learning how Construct 2 handles things and sometimes forget how flexible Construct 2 is.

I have never needed a loop that ran until a variable is not equal to X.
I found out it can be done with 'Repeat'
I have never needed a loop to have 'wait' in it before. It is possible because I've seen it done and know how to do it now. It wasn't working in my 'Repeat' loop, but it was working in other loops I tested out. My structure was wrong on that 'Repeat' loop probably, but I am not using it anymore.
B
59
S
33
G
13
Posts: 223
Reputation: 12,105

Post » Thu Jun 30, 2016 6:44 am

I explained my issue in my capx and gave the needed info and asked for a function that worked only when a variable is equal to 1 or 2, and I didn't want the function to have to check every single instance when it ran. I gave the answer of groups in the original post. I was only trying to find a solution that didn't have to add a group leader and didn't run all the time. I ended up with a mixture of what I wanted and what I didn't. Every half second Construct 2 checks 12 objects instead of 624. I was wanting it as a trigger, but it is becoming to much trouble. This solution is simple and works.


The point of the slowed loop was, I was going to put it in a trigger event.
This prevents needless checks on ticks.
B
59
S
33
G
13
Posts: 223
Reputation: 12,105

Post » Thu Jun 30, 2016 9:15 am

Thank you guys for helping. :)
B
59
S
33
G
13
Posts: 223
Reputation: 12,105

Previous

Return to How do I....?

Who is online

Users browsing this forum: jasontoups, tarek2 and 1 guest