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
28
S
5
Posts: 475
Reputation: 2,533

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: 461
Reputation: 6,087

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
28
S
5
Posts: 475
Reputation: 2,533

Post » Thu Jul 18, 2013 11:25 am

Scirra Founder
B
378
S
220
G
84
Posts: 23,871
Reputation: 188,197

Post » Thu Jul 18, 2013 4:15 pm

Ah there it is - thanks, Ashley!
B
28
S
5
Posts: 475
Reputation: 2,533


Return to How do I....?

Who is online

Users browsing this forum: mercuryus, Moordhuis, RetroSpock, TRMG and 11 guests