Using Controllers


06-03-2010 13:09:08


Consider the following code:

MyGUI::ControllerManager& manager = MyGUI::ControllerManager::getInstance();
MyGUI::ControllerItem* item = manager.createItem(MyGUI::ControllerFadeAlpha::getClassTypeName());
controller = item->castType<MyGUI::ControllerFadeAlpha>();
manager.addItem(main_menu, controller);

1) Each time I want to animate my "main_menu" widget, do I have to create a new instance of the controller or could I reuse the old one somehow? Please explain how I can "reset" the controller so that the "main_menu" can re-animate, e.g. user clicked on a sub-menu item and pressed Esc to go back to the main menu.

2) Instances of the ControllerItem that is created by the ControllerManager as in the above code, does MyGUI take care of the memory or do I have to manually delete those pointers when done?