Optimization: Move off-screen or create/destroy?

0 favourites
  • 5 posts
From the Asset Store
Move Block
$10 USD
Captivating puzzle game. With challenging gameplay, this game will keep you very engaged.
  • 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?


    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! ^^

  • 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).

    <img src="http://www.angelsoftware.fr/wp-content/uploads/alpha_04.png" border="0" />

    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.

    <img src="http://www.angelsoftware.fr/wp-content/uploads/coffeetime_prototype_level.jpg" border="0" />

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok thanks... makes sense i guess not worrying about it

  • 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)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)