ImageButton Class
Implements game button functionality. This button can be filled with image. It supports diferent image for normal and pressed state. These two states can be placed in two separate files, or in one file with two frames.
Item Index
Methods
Attributes
Methods
_drawImage
canvas
Draw Image mode, display image based on button state
Parameters:
-
canvas
CanvasCanvas used to draw sequence
_drawSequence
canvas
Method do draw sequence mode, display frame based on button state.
Parameters:
-
canvas
CanvasCanvas used to draw sequence
aftetInit
() protected
Init button. This method is called from class constructor and it is usually no needed to change it.
draw
canvas
Draw method draws the button.
Parameters:
-
canvas
CanvasCurrent game canvas
init
() protected
Init button. This method is called from class constructor and can be used in overwritten classes as a class constructor.
Properties
frameHeight
Integer
Set frame height. Button's image is automatically divided into frames acording to frame width and height.
Example:
var button = new ImageButton ({
image : res.img.continueButton,
x : System.width/2,
y : top,
frameWidth : res.img.continueButton.width,
frameHeight : res.img.continueButton.height / 2,
});
frameWidth
Integer
Set frame width. Button's image is automatically divided into frames acording to frame width and height.
Example:
var button = new ImageButton ({
image : res.img.continueButton,
x : System.width/2,
y : top,
frameWidth : res.img.continueButton.width,
frameHeight : res.img.continueButton.height / 2,
});
image
Bitmap | String
Image on the button. If image contains two frames, first frame is used for normal state and second for pressed state.
Example:
var button = new ImageButton ({
image : res.img.continueButton,
x : System.width/2,
y : top,
frameWidth : res.img.continueButton.width,
frameHeight : res.img.continueButton.height / 2,
});
imagePressed
Bitmap | String
Image on pressed button, displays image when user click on the button. The pressed image can be palced also in one file with normal image.
Example:
var button = new ImageButton ({
image : res.img.continueButton,
imagePressed : res.img.continueButtonPressed,
x : System.width/2,
y : top,
});
mode
Symbol
Displaying game button mode: 1. #sequence, this mode calculate based frameWidth or frameHight, segiences and frames Maximum allowed frames for game button is Two 2. #image, game button expect two images. One for normal state second one for pressed state. If pressedImage is not set by default is set to the image
sequence
Array
This property sets sequence of the button frames.