Class cocos.menu.MenuItem

         object --+    
                  |    
cocosnode.CocosNode --+
                      |
                     MenuItem
A regular menu item. It triggers a function when it is activated

Methods

  __init__(self, label, callback_func)
Creates a new menu item
(x1,x2,y1,y2) get_box(self)
Returns the box that contains the menu item.
  draw(self)
This is the function you will have to override if you want your subclassed to draw something on screen.
  on_key_press(self, symbol, modifiers)
  on_text(self, text)
bool is_inside_box(self, x, y)
Returns whether the point (x,y) is inside the menu item.
  on_selected(self)
  on_unselected(self)
  on_activated(self)
Inherited from cocosnode.CocosNode: __contains__, add, are_actions_running, do, get, get_ancestor, get_children, on_enter, on_exit, pause, pause_scheduler, remove, remove_action, resume, resume_scheduler, schedule, schedule_interval, stop, transform, unschedule, visit, walk Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Instance Variables

Inherited from cocosnode.CocosNode: actions, camera, children, children_anchor_x, children_anchor_y, children_names, grid, is_running, rotation, scale, scheduled_calls, scheduled_interval_calls, skip_frame, to_remove, transform_anchor_x, transform_anchor_y, visible, x, y

Class Variables

  selected_effect = None
  unselected_effect = None
  activated_effect = None
Inherited from cocosnode.CocosNode: anchor, anchor_x, anchor_y, children_anchor, parent, position, transform_anchor

Method Details

__init__

(Constructor) __init__(self, label, callback_func)
Creates a new menu item
Parameters:
label : string
The label the of the menu item
callback_func : function
The callback function
Overrides:
cocosnode.CocosNode.__init__

draw

draw(self)

This is the function you will have to override if you want your subclassed to draw something on screen.

You must respect the position, scale, rotation and anchor attributes. If you want OpenGL to do the scaling for you, you can:

def draw(self):
    glPushMatrix()
    self.transform()
    # ... draw ..
    glPopMatrix()
Overrides:
cocosnode.CocosNode.draw