View Full Version : dynamic OverlayEntity change

10-02-2011, 08:47 PM
Hello... I'm thinking about an optimal way to dynamicly change an image connected with an OverlayEntity. Is there any method to set it? I would like to set N different images to one pointer from time to time but can't figure out how to do that ... I tried to use CreateOverlayMethod twice for one pointer but after setting its visibility to false it was still visible like there was another instance of that entity somewhere "in the air"... I just don't get it.... I could just create N pointers with N OverlayEntities and manipulate with their visibility but that would be the worst solution...

10-03-2011, 01:17 AM
You can change an image "on the fly" in an OverlayRenderComponent by changing its "fileName" parm. The CreateOverlayEntity utility function creates an OverlayRenderComponent, as does CreateOverlayButtonEntity and pretty much anything that requires a 2d visual, so this would work for all of them:

First, create your entity:

Entity *pEnt = CreateOverlayEntity(pParent, "myEnt", "skeleton.rttex", 0, 0);

Ok, it's been added and is displaying "skeleton.rttex". To change it later, you would do this:

//either use pEnt that you saved somewhere before, or grab it again like this:
//Entity *pEnt = GetEntityRoot()->GetEntityByName("myEnt);


It will load the new image and adjust its size variables/centering, etc as needed.

Because "fileName" is just a variable of OverlayRender, you can use the MessageManager to schedule changes after X mount of milliseconds and such, useful for psuedo-animations.

10-03-2011, 07:42 AM
Thank you very much :) Is there any detailed documentation where I could find a list of each component's varables ? It's hard to guess their names when they're string parameters in those methods...

10-07-2011, 05:22 AM
Sorry - I'd like to have a page on the Proton Wiki for every component explaining how to use it but.. time. :sweatdrop: Anybody want to help me with this? I could check over anything added for correctness.

Until that happens, your best bet is to look in the source file itself or ask here like you did. I can add usage examples to svn for tricky things if needed.

Sometimes I put examples in the .h file, and if you check the .cpp's OnAdd(), you can see all the variables used.

For instance, this is from RectRenderComponent::OnAdd():

m_pBorderColor = &GetVarWithDefault("borderColor", Variant(MAKE_RGBA(255,255,255,0)))->GetUINT32();

This tells you there is a RGBA "borderColor" parm at the component level. Changing it does indeed change the border color. The default has 0 alpha, which means don't render it. So to get a border, you'd have to change this var.