I just finished up a quick class I made in Codea. This class allows quick and dynamic creation of text-based menus. The code can be found on the link below:
Link to Code
The menu class requires several different parameters to setup the new object. To setup a new menu use the following code:
menuName = HighlightMenu(pos,title,ftSize,titleColor,itemColor,hlColor) : Creates a new Menu Object
- pos = (Vec2) This determines the position of the 1st Menu Option. For example, vec2(WIDTH/2,HEIGHT/2) will place the 1st Option in the Center of the screen. All additional objects will be displayed below this location at a distance of pos.y+(ftSize*n); where n = menu position number.
- title = (String) Sets the title for the menu.
- ftSize = (Int) Determines the size of the menu options. The title size is determined by ftSize + 15.
- titleColor = (Vec3) Sets the Color of the Title.
- itemColor = (Vec3) Sets the Color of a menu option when not selected.
- hlColor = (Vec3) Sets the Color of a menu option when it is selected.
menuName:addNew(text,function) : Adds a new Menu Option Object to the Menu Object
- text = (String) Sets the Text for a button.
- function = (String) Sets the function to be performed when selected. This must be a string! A good example of this would be menuName:addNew(“Some Option”,”someOption()”)
menuName:draw() : Draws the Menu and Menu Objects
mainMenu:touched(touch) : Handles the Touch Events for the Menu