|November 12, 2009 at 5:16 am #218384|
Hi Forum, I’m trying to build a preferences screen where a player can select a game piece’s size. I’d like to have three buttons – small, medium, large, and have the selected choice toggle ‘on’ while the others toggle ‘off’. This sounds like what MenuItemToggle was made for, except it shows only one button and toggles between button 1 and button 2. I’ve tried a few solutions like manually setting button toggles, using sprites and even nesting ItemToggles. No joy.
Is MenuItemToggle only good for displaying a single menuItems in its container of menuItems, or can it toggle amongst ‘three-in-a-row’ MenuItems? I want to display all three toggle options on screen at the same time, not cycle through ‘hidden’ options in the toggle stack.
This will toggle one image and it ignores the button positioning, but how does one toggle three images? Is it better to just code that action manually?
Thanks for sharing your ideas.
|November 16, 2009 at 1:58 am #266185|
What I did for a similar situation is subclass MenuItem, adding a property for isActive. That way, when an item is pressed it will be active, and deactivate all other children of the parent Menu class. Here’s my activate class for my subclassed MenuItem:
I also overwrote the MenuItem draw function to show an active status:
I define an “active” image that is displayed when a menuitem is active.
You must be logged in to reply to this topic.