0

A "Button" can be created by:

ui::Button* button = ui::Button::create("button.png");

How can we use a sprite sheet for this ?

EDIT: If I just put the name of a sprite frame for example:

ui::Button* button = ui::Button::create("button");

Then it doesn't detect it - thinks there is a missing image.

Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190

1 Answers1

4

You could pass an extra argument to the ui:Button:create function.

You could use

ui::Button* button = ui::Button::create("button","","",TextureResType::PLIST);

to create a button with a sprite frame named "button".

For more information, please refer to the UIButton.h and UIButton.cpp files.

zilongshanren
  • 489
  • 4
  • 8