API Docs for: 0.1.0
Show:

CG.Menu Class

Extends CG.Class
Module: CG

CG.Menu collects buttons an displays them with the defined margin


                        var menu = new CG.Menu({
                          x: 100,
                          y: 100,
                          margin: 10
                        })
                        
                        button = new CG.Button({
                           image: Game.asset.getImageByName('button'),
                           position: new CG.Point(Game.width2, 100),
                           text: 'Menu Button 1',
                           font: font,
                           callback: callbackTest
                        })
                        button.name = '#mbutton 1#'
                        menu.addButton(button)
                        
                        button = new CG.Button({
                           image: Game.asset.getImageByName('button'),
                           position: new CG.Point(Game.width2, 100),
                           text: 'Menu Button 2',
                           font: font,
                           callback: callbackTest
                        })
                        button.name = '#mbutton 2#'
                        menu.addButton(button)
                        
                        button = new CG.Button({
                           image: Game.asset.getImageByName('button'),
                           position: new CG.Point(Game.width2, 100),
                           text: 'Menu Button 3',
                           font: font,
                           callback: callbackTest
                        })
                        button.name = '#mbutton 3#'
                        menu.addButton(button)
                        
                        // add the menu to the layer
                        layermenu.addElement(menu)
                        

Item Index

Properties

Methods

addButton

(
  • button
)

adds an CG.Button to the buttons array

Parameters:

  • button Button

draw

()

init

(
  • options
)

Options: x {number} y {number} margin {number}*

Parameters:

Returns:

:

update

()