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
30
S
7
G
1
Posts: 505
Reputation: 3,343

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,097

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
30
S
7
G
1
Posts: 505
Reputation: 3,343

Post » Thu Jul 18, 2013 11:25 am

Scirra Founder
B
385
S
227
G
86
Posts: 24,148
Reputation: 190,849

Post » Thu Jul 18, 2013 4:15 pm

Ah there it is - thanks, Ashley!
B
30
S
7
G
1
Posts: 505
Reputation: 3,343


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], pynam and 5 guests