CG.Menu Class
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)
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:
-
options
Object
Returns:
: