Optimization: Move off-screen or create/destroy?

Get help using Construct 2

Post » Wed Jul 17, 2013 11:45 am

I've been wondering over something which i scoured the forums for and it has to do with optimization. Currently I'm working on a radial menu system for my game, which oddly enough is the first thing i tackled when trying to learn C2.

Right now i create all menu objects "on start of layout" and position them off-screen. When they are needed i simply position them on the "stage" and when they are no longer required, i move them back off-screen. While doing this a thought struck me that having too many objects might slow down the system?

According to http://www.scirra.com/manual/134/performance-tips, off-screen objects aren't rendered but i still wanted to hear your opinion on this.

Is it better to create the menu objects when they are needed, position them and the destroy them when not needed?

OR

Create them "on start of layout" and position them off-screen, move them them when needed and then back again?

In the provided link they also state that "the GPU is also smart enough to know not to render any content that appears outside the window - even when a single image is only partially on-screen". So how does partly visible images affect performance? Right now i position menu objects by using "-module.Width" and "-module.Height" which basically puts them right off-screen. Is it safer to put them at "-1000" or something to ensure them not being partially visible?

Thanks! ^^hdnine2013-07-17 11:47:25
B
7
S
1
Posts: 38
Reputation: 405

Post » Wed Jul 17, 2013 12:33 pm

i've made some test on this for my current project ("Space Tako Invasion")
for exemple on trail missile or explosion (destroy when animation finish using a famillie)
And using a classic create/destroy technic with a fade behavior + outside the screen.

the problem with this technic is that increase a lot the number of objects in Construct2 and this is doom completly the perf on mobile (test on a my galaxy note 10.1 tablet).

I test a simple pool managing system with a variable ("in_use")but the problem is that i need to select all and manage the variables so this isn't efficient too.

For particules the most usefull and fast was the particules system of construct2 1 object for all the particules trails, you only need to know that if you destroy particules object you will destroy the instance so all the particules (of your trail for exemple) will be destroy too (just manage the time before destory and that will be ok).


the last test i've done it for the my other game test "Coffee Time"

i use trigger on map to make 2 test :
1 - the trigger just initialisate a variable ("active") to make the ennemies ia active (move, ect...)
2 - the trigger create object ennemis and the ennemies spwaner on the map.

the 2 test was really bad on mobile with cocoonjs because when i create object i thing the allocate of memory is done and i notice freeze.
it's only appear if you've have big gfx.

So depending of the size of the gfx and you're need, a simple variable is a better way to manage ennemies on level.
for dynamic and fast object (low gfx size) if it's just particules use the particules object.
If it's for exemple fire, use create/destroy.
ThunderZ2013-07-17 12:34:14
B
85
S
14
G
6
Posts: 72
Reputation: 7,237

Post » Wed Jul 17, 2013 2:57 pm

If you are using less than 100 objects, the differences between the two methods you describe are probably negligable. Optimisation: don't waste your time
Scirra Founder
B
378
S
220
G
84
Posts: 23,868
Reputation: 188,109

Post » Thu Jul 18, 2013 9:47 am

Ok thanks... makes sense i guess not worrying about it
B
7
S
1
Posts: 38
Reputation: 405

Post » Thu Jul 18, 2013 10:04 am

yes depending you're use and the number of objects (and the size of the bitmap source), in general using create/destroy is very fast and fine.

You just need some trick or different design if you use lot of objects or big one (ex: create 10 big ennemy with big bitmap in a single tick)
B
85
S
14
G
6
Posts: 72
Reputation: 7,237


Return to How do I....?

Who is online

Users browsing this forum: alextro, christina, Kyatric, omnipaws and 10 guests