Rotating widgets/subskins


10-12-2009 13:53:46

I want to have a widget that is rotated as things happen in my game. Preferably this would happen so that just one subskin in a widget rotates, while others stay stationary.

I think the RotatingSkin subskin type is there for this purpose, but how do I use it? If I have read the API correctly, the Widget interface does not allow me to get to subskins, so I can never get a reference to the RotatingSkin object, neither is there anything on the Widget level for this. Is the only way implementing a new widget type that gets lower level control over the subskins?

I don't think the usage of RotatingSkins is covered by any demos, although I'd be more than happy to be proven wrong on this.

Any help would be appreciated.


10-12-2009 15:46:00

Yeah, right now it is not shown in demos, but there is similar thing with access to subskin in Demo_Gui (ColourWindow.cpp).
Here's short example.
MyGUI::RotatingSkin* rotatingSkin = widgetWithProperMainSkin->getSubWidgetMain()->castType<MyGUI::RotatingSkin>();

getSubWidgetMain return first subskin in your skin, then you cast it to proper type.


11-12-2009 06:36:24

Thank you, works beautifully.

Just confirming that my set up is OK: The rotating texture is between a background and a border on top. There's nothing I can do in the skin definition to place another subskin below the main skin, so I need to have the background on a parent widget, add a child widget into that, with the rotating subskin as the first one defined. Is that correct?

A feature suggestion: It would in general be very nice if you could specify the layer a subskin is placed on, as an attribute to the BasisSkin element.


11-12-2009 08:01:39

I suggest you just make skin for background on simple Widget and then attach another Widget (with skin that have single rotatingsubskin) over it.