Skip to content
fahimc edited this page Sep 6, 2012 · 2 revisions

You can create buttons which uses a spritesheet and you can add text. Easily activate and deactivate the button.

Creating a Spritesheet

The button requires a spritesheet which needs to contain 4 states vertically in the following order:

  • Up state
  • Over state
  • Down state
  • Disabled state

Below is an example of how to use the Button class.

        var button = new Button();
	button.build();
	button.className("button");
	button.asset(ResourceManager.getAssetByName("button"));
	button.width(150);
	button.height(30);
	button.labelClassName("buttonLabel");
	button.setStyle();
	this.addChild(button);
	button.activate();
	button.text("Next");

##Adding a Spritesheet Use the asset function and pass in either the source location and or and Image object.

 button.asset(ResourceManager.getAssetByName("button"));

##Adding text
button.text("Next");

Clone this wiki locally