Class cocos.menu.Menu

layer.Layer --+
              |
             Menu

Abstract base class for menu layers.

Normal usage is:

Methods

  __init__(self, title='')
  create_menu(self, items, selected_effect=None, unselected_effect=None, activated_effect=None)
Creates the menu
  draw(self)
  on_text(self, text)
  on_key_press(self, symbol, modifiers)
  on_mouse_release(self, x, y, buttons, modifiers)
  on_mouse_motion(self, x, y, dx, dy)

Class Variables

  is_event_handler = True
Receives pyglet events
  select_sound = None
  activate_sound = None

Method Details

create_menu

create_menu(self, items, selected_effect=None, unselected_effect=None, activated_effect=None)

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:
items : list
list of MenuItem that will be part of the Menu
selected_effect : function
This action will be executed when the MenuItem is selected
unselected_effect : function
This action will be executed when the MenuItem is unselected
activated_effect : function
this action will executed when the MenuItem is activated (pressing Enter or by clicking on it)