A Layer that implements a simple menu
This module provides a Menu class. Menus can contain regular items (which trigger a function when selected), toggle items (which toggle a flag when selected), or entry items (which lets you enter alphanumeric data).
To use a menu in your code, just subclass Menu and add the menu to an Scene or another Layer.
Bases: cocos.layer.base_layers.Layer
Abstract base class for menu layers.
Normal usage is:
- create a subclass
- override __init__ to set all style attributes, and then call create_menu()
- Finally you shall add the menu to an Scene or another Layer
Creates the menu
The order of the list important since the first one will be shown first.
Example:
l = []
l.append( MenuItem('Options', self.on_new_game ) )
l.append( MenuItem('Quit', self.on_quit ) )
self.create_menu( l, zoom_in(), zoom_out() )
Parameters: |
|
---|
Receives pyglet events
Bases: cocos.menu.BaseMenuItem
A menu item that shows a label.
Bases: cocos.menu.MultipleMenuItem
A menu item for a boolean toggle option.
Example:
items.append( ToggleMenuItem('Show FPS:', self.on_show_fps, director.show_FPS) )
Bases: cocos.menu.MenuItem
A menu item for switching between multiple values.
Example:
self.volumes = ['Mute','10','20','30','40','50','60','70','80','90','100']
items.append( MultipleMenuItem(
'SFX volume: ',
self.on_sfx_volume,
self.volumes,
8 ) )
Bases: cocos.menu.MenuItem
A menu item for entering a value.
When selected, self.value is toggled, the callback function is called with self.value as argument.
Bases: cocos.menu.BaseMenuItem
A menu item that shows a selectable Image
Bases: cocos.menu.MenuItem
A menu item for selecting a color.
Example:
colors = [(255, 255, 255), (100, 200, 100), (200, 50, 50)]
items.append( ColorMenuItem(
'Jacket:',
self.on_jacket_color,
colors ))
Predefined action that performs a slight rotation and then goes back to the original rotation position.
Predefined action that rotates to 0 degrees in 0.1 seconds
Predefined action that scales to 1.5 factor in 0.2 seconds
Predefined action that scales to 1.0 factor in 0.2 seconds
Enter search terms or a module, class or function name.