Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
sprite:AddChildAt... sprite:RemoveChildAr... sprite:setVisible and my "paranoid" optimizations ;) — Gideros Forum

sprite:AddChildAt... sprite:RemoveChildAr... sprite:setVisible and my "paranoid" optimizations ;)

GregBUGGregBUG Guru
edited January 2012 in General questions
hi!
in my particle engine i'm using a fixed array (to avoid insert and remove element and speed-up things)
every single "slot" of array are reused (if needed) when the particle end.

when the particle is "dead" and not visible i use sprite:setVisible(false) but the documentation says: " Sprites that are not visible are also taken into consideration while calculating bounds."...

my question is:

is more efficent that i add/remove the sprites with "addchildAt/removeChildAt" or not remove sprite and uses setVisible(true/false) ?

i'm not paranoid but i'm try to optimize the particle engine in time-critical sections.

any advice? :-B
TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
www.tntengine.com

Comments

  • atilimatilim Maintainer
    Hi Gianluca,

    I would decide this according to the ratio of visible and hidden particles. If there are so many hidden particles, add/remove is efficient, if there are not so many hidden particles then hide/show is efficient.

    Also one other way can be pushing the limits of the particle engine and observe when the fps starts to drop from 60 (not on PC but on mobile).

    cheers,
  • ... for now i'm happy of the performances...
    today i heavy modified the main update function and optimized the best that i can...:)
    now i'll try to add calculating ratio of visible and hidden particles and decide if remove or hide particle...

    another solution could:

    1. a new command like ex: "setHide()" identical to setVisible "without consideration while calculating bounds" :D
    2. convert in native code...

    what do you think about new command ? :D
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • atilimatilim Maintainer
    hmm.. there is a misunderstanding here. :-\" In fact, setVisible is a very fast function. It only modifies a visibility flag and nothing else.

    "Sprites that are not visible are also taken into consideration while calculating bounds."
    -> Assume that you have a sprite hierarchy, and you get the bounds (width and height) of this hierarchy by calling getWidth() and getHeight(). Even if you change the visibility of a sprite in this hierarchy, the functions getWidth() and getHeight() return the same bounds.
  • ouch!!!
    sorry my fault!!!
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
Sign In or Register to comment.