PDA

View Full Version : About entity layer control



youngvleo
01-15-2013, 09:49 AM
Hi
Just a newbie question, is there any grace way to control entity layers manually in my game GUI?

e.g. Have 3 entities: main menu, shop, user info bar
When enter shop from main menu, how should I keep user info bar staying on top layer of screen, instead of being overlapped by shop entity?

Thanks a lot :)

Seth
01-15-2013, 01:43 PM
One solution is put them in dummy empty entities, using entities as folders.

Make these at the start of the game:

Root->GUI
Root->Overlay

Or, in code:

GetRootEntity()->AddEntity(new Entity("GUI"));
GetRootEntity()->AddEntity(new Entity("Overlay"));

Now, anything you add to the entity Overlay (more entities) will always render over GUI, no matter what order they are added/removed later.

To add the overlay, just make sure for its parent you use:

Entity *pParent = GetEntityRoot()->GetEntityByName("Overlay");

CreateMyOverlayStuffWithThisParent(pParent);

youngvleo
01-15-2013, 03:46 PM
It's working brilliantly following your thread, Cheers!
Thanks a Lot :o