Ezelia / EZGUI

EZGUI - The missing GUI for Pixi.js and Phaser.io
http://ezgui.ezelia.com
440 stars 95 forks source link

Way to iterate through child Components (primarily, of List)? #34

Open Shadowstep33 opened 8 years ago

Shadowstep33 commented 8 years ago

Hi, particularly if I define a list - is there a way to iterate through the components that are added to it? I notice if I look in it's children, there are a couple miscellaneous things but it seems the child at index 2 is a container that has the components of the list I'm looking for. But iterating through it seems to produce some unintended results. Currently, what I am doing is this:

    for(var c in EZGUI.components.playerBagList.children[2].children){
        if(!(EZGUI.components.playerBagList.children[2].children[c] instanceof Button))
            continue;

... //All further actions (such as handlers) are done on EZGUI.components[EZGUI.components.playerBagList.children[2].children[c].guiID]

//Perhaps EZGUI.components.playerBagList.components? 
        }

this is suitable but seems like a bit of a long winded way to do it (not to mention if I ever change the order of playerBagList's children things will get weird). Perhaps I am just being lazy... lol

Anyways, love the library so far!