Installation
- Copy
gui.js
tolib/plugins/
- Add plugin in main.js:
'plugins.gui'
- On your draw code:
if(ig.gui.show) ig.gui.draw();
- Boom. Easy-GUI
Elements
Functions:
ig.gui.element.add(properties);
add: ig.gui.element.action('getByName', 'name');
getByName ig.gui.element.action('getByGroup', 'name');
getByGroup ig.gui.element.action('show', 'name')
show ig.gui.element.action('showGroup', 'name');
showGroup ig.gui.element.action('hide', 'name')
hide ig.gui.element.action('hideGroup', 'name');
hideGroup ig.gui.element.action('toggle', 'name');
toggle ig.gui.element.action('toggleGroup', 'name');
toggleGroup ig.gui.element.action('remove', 'name');
remove ig.gui.element.action('removeGroup', 'name');
removeGroup ig.gui.element.action('enable', 'name');
enable ig.gui.element.action('enableGroup', 'name');
enableGroup ig.gui.element.action('disable', 'name');
disable ig.gui.element.action('disableGroup', 'name');
disableGroup ig.gui.element.action('disableAll');
disableAll Add properties
name: Element name
group: Group name
title: Element title. Shown in the lower-left of the element if enabled.
keybind: Element bound key. Allows a key to activate the button as well as the mouse. (must be the name that the key is bound with in Main.js)
showTitle: Show the element's title on the element. The default is false
showBind: Show the key bound to the element. The default is false (it simply shows the name of the key that is bound in Main.js)
count: An integer attached to the element, can be used for various purposes.
icon: An icon to be shown on top of the element, during all states.
size: Size of element
pos: Position to place this element on screen
disabled: Avoids behaviors and state changes
alpha: Specifies the alpha transparency. The default is 1 (fully opaque).
toggle: Changes state and remains there until you click. The default is false
active: Toggle initial state. Default is false,
mouseDown: Sets a function that runs continuously while the mouse button is pressed
click: Sets a function that runs every time you press the mouse button
state: Allows state and behavior changes
normal: Normal state of element (Required, other states: **hover** and **active**)
image: Image resource.
tile: Number of tile. (Optional, you can use a simple image)
tileSize: Tile size
Quick button:
ig.gui.element.add({
name: 'button_name',
group: 'group_name',
size: { x: 28, y: 56 },
pos: { x: 0, y: 37 },
state: {
normal: {
image: new ig.Image('media/minibutton.png')
}
},
click: function() {
// Action!
}
})
Full example
ig.gui.element.add({
name: 'button_name',
group: 'group_name',
title: 'button_title',
showTitle: true,
keybind: 'button_key',
showBind: true,
icon: new ig.Image('media/icon.png'),
size: { x: 32, y: 32 },
pos: { x: 15, y: 10 },
disabled: false,
alpha: 0.5,
toggle: true,
active: false,
state: {
normal: {
image: new ig.Image('media/buttons.png'),
tile: 3,
tileSize: 32
},
hover: {
image: new ig.Image('media/buttons.png'),
tile: 4,
tileSize: 32
},
active: {
image: new ig.Image('media/buttons.png'),
tile: 5,
tileSize: 32
}
},
mouseDown: function() {
// Mouse down!
},
click: function() {
console.log(this); // Print this button ;)
}
})
Change properties
(ig.gui.element.action('getByName', 'button_name')).alpha = 0.5;
Cursor
Functions:
ig.gui.cursor.set(image);
set ig.gui.cursor.clear();
clear Mouse binds (Important!):
The plugin binds left button to mouse1.
If your click doesn't work maybe this is the problem!
#4