Proper Programming for Performance

Get help using Construct 2

Post » Wed Jul 17, 2013 8:23 pm

I was wondering if anyone had some "programming no-nos" for Construct 2. I'm starting to use a lot of "every 0.1 seconds, add 1 to instance varible; if instance variable = 10, run this event/trigger once" and while it's working fine, I'm worried once I add more and more to the game, the performance will start to take a huge hit.
B
42
S
12
G
1
Posts: 541
Reputation: 4,215

Post » Wed Jul 17, 2013 9:42 pm

I'm all for optimization too, and you can find my thoughts and some techniques in this tutorial, but as Ashley pointed out in this blog article, events logic won't be a problem in most cases, as the rendering is usually the limiting factor of framerate.

For the typical case you described (+1 every X seconds, do once this event when hitting a fixed goal), I prefer to go with recursive functions. They give you a good control over the situation, and they are trigger-based, meaning they won't be evaluated every tick for the rest of the runtime.
Here is an example of how I usually do it.
B
17
S
8
G
4
Posts: 473
Reputation: 6,211

Post » Thu Jul 18, 2013 12:47 am

This seems brilliant, but I'm confused as to why it only works when using a function as opposed to putting the function actions in the Else condition.

*EDIT* Nevermind - I got it :) Thanks!ome6a17172013-07-18 00:50:18
B
42
S
12
G
1
Posts: 541
Reputation: 4,215

Post » Thu Jul 18, 2013 11:25 am

Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Thu Jul 18, 2013 4:15 pm

Ah there it is - thanks, Ashley!
B
42
S
12
G
1
Posts: 541
Reputation: 4,215


Return to How do I....?

Who is online

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