|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpulpcore.sprite.Sprite
pulpcore.sprite.ImageSprite
pulpcore.sprite.Button
public class Button
The Button is a Sprite that behaves like a common UI push button. A
Button has three visual states: normal, hover, and pressed. Call
isClicked() to check if the user clicked the button. By default, a Button's cursor
is Input.CURSOR_HAND.
By default, Buttons use pixel level checking for intersection tests. Use
ImageSprite.setPixelLevelChecks(boolean) to disable this feature.
| Field Summary |
|---|
| Fields inherited from class pulpcore.sprite.ImageSprite |
|---|
antiAlias |
| Fields inherited from class pulpcore.sprite.Sprite |
|---|
alpha, anchorX, anchorY, angle, CENTER, DEFAULT, EAST, enabled, height, NORTH, NORTH_EAST, NORTH_WEST, pixelSnapping, SOUTH, SOUTH_EAST, SOUTH_WEST, visible, WEST, width, x, y |
| Constructor Summary | |
|---|---|
Button(CoreImage[] images,
double x,
double y)
|
|
Button(CoreImage[] images,
double x,
double y,
boolean isToggleButton)
|
|
Button(CoreImage[] images,
int x,
int y)
|
|
Button(CoreImage[] images,
int x,
int y,
boolean isToggleButton)
|
|
| Method Summary | |
|---|---|
void |
clearKeyBinding()
Clears the key binding for this button. |
static Button |
createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y)
|
static Button |
createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
double textAnchorX,
double textAnchorY,
boolean offsetPressedText)
|
static Button |
createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
double textAnchorX,
double textAnchorY,
boolean isToggleButton,
boolean offsetPressedText)
|
static Button |
createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
int textAnchor,
boolean offsetPressedText)
Deprecated. |
static Button |
createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
int textAnchor,
boolean isToggleButton,
boolean offsetPressedText)
Deprecated. |
static Button |
createLabeledButton(String text,
int x,
int y)
|
static Button |
createLabeledToggleButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y)
|
static Button |
createLabeledToggleButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
double textAnchorX,
double textAnchorY,
boolean offsetPressedText)
|
static Button |
createLabeledToggleButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
int textAnchor,
boolean offsetPressedText)
Deprecated. |
static Button |
createLabeledToggleButton(String text,
int x,
int y)
|
int[] |
getKeyBinding()
Gets a copy of the key bindings for this button. |
boolean |
isClicked()
Determines if this button was clicked since the last frame. |
boolean |
isPressedDown()
Determines if this button was pressed and the mouse is still held down over the button. |
boolean |
isSelected()
Determines if this button is selected. |
boolean |
isToggleButton()
|
void |
setKeyBinding(int keyCode)
Sets the key binding for this button to the specified key code. |
void |
setKeyBinding(int[] keyCodes)
Sets the key binding for this button to the specified key codes. |
void |
setSelected(boolean isSelected)
Sets whether this button is selected. |
void |
update(int elapsedTime)
Updates all of this Sprite's properties. |
| Methods inherited from class pulpcore.sprite.ImageSprite |
|---|
drawSprite, getImage, getNaturalHeight, getNaturalWidth, getPixelLevelChecks, isOpaque, isTransparent, propertyChange, setAnchor, setAnchorToHotSpot, setImage, setImage, setPixelLevelChecks |
| Methods inherited from class pulpcore.sprite.Sprite |
|---|
bindLocationTo, bindSizeTo, clearCursor, clearDirtyRect, contains, draw, getBlendMode, getCursor, getDirtyRect, getFilter, getLocalX, getLocalY, getParent, getRoot, getScene2D, getTag, getViewX, getViewX, getViewY, getViewY, intersects, isDirty, isEnabled, isEnabledAndVisible, isMouseDoubleClicked, isMouseDown, isMouseHover, isMouseOver, isMousePressed, isMouseReleased, isMouseTripleClicked, isMouseWheelRotated, isPick, isPickEnabledAndVisible, move, move, move, move, move, move, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, removeFromParent, scale, scale, scale, scale, scale, scale, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, setAnchor, setBlendMode, setCursor, setDirty, setFilter, setLocation, setLocation, setSize, setSize, setTag, translate, translate, updateDirtyRect |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Button(CoreImage[] images,
int x,
int y)
images - an array of three images: normal, hover, and pressed.
public Button(CoreImage[] images,
int x,
int y,
boolean isToggleButton)
images - an array of three images: normal, hover, and pressed.
Use six images for toggle buttons (unselected and selected).
public Button(CoreImage[] images,
double x,
double y)
images - an array of three images: normal, hover, and pressed.
public Button(CoreImage[] images,
double x,
double y,
boolean isToggleButton)
images - an array of three images: normal, hover, and pressed.
Use six images for toggle buttons (unselected and selected).| Method Detail |
|---|
public boolean isToggleButton()
public int[] getKeyBinding()
setKeyBinding(int),
setKeyBinding(int[]),
clearKeyBinding()public void clearKeyBinding()
getKeyBinding(),
setKeyBinding(int),
setKeyBinding(int[])public void setKeyBinding(int keyCode)
getKeyBinding(),
setKeyBinding(int[]),
clearKeyBinding()public void setKeyBinding(int[] keyCodes)
getKeyBinding(),
setKeyBinding(int),
clearKeyBinding()public void setSelected(boolean isSelected)
public boolean isSelected()
public void update(int elapsedTime)
Sprite
update in class ImageSpritepublic boolean isClicked()
public boolean isPressedDown()
To detect a click, use isClicked().
public static Button createLabeledButton(String text,
int x,
int y)
public static Button createLabeledToggleButton(String text,
int x,
int y)
public static Button createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y)
public static Button createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
int textAnchor,
boolean offsetPressedText)
public static Button createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
double textAnchorX,
double textAnchorY,
boolean offsetPressedText)
public static Button createLabeledToggleButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y)
public static Button createLabeledToggleButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
int textAnchor,
boolean offsetPressedText)
public static Button createLabeledToggleButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
double textAnchorX,
double textAnchorY,
boolean offsetPressedText)
public static Button createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
int textAnchor,
boolean isToggleButton,
boolean offsetPressedText)
images - the images to use. If null, simple gray images are created to fit the textfont - the font to use for rendering the text label. If null, the system font is used.offsetPressedText - Set to true to offset the button's text when the button is pressed.
public static Button createLabeledButton(CoreImage[] images,
CoreFont font,
String text,
int x,
int y,
int textX,
int textY,
double textAnchorX,
double textAnchorY,
boolean isToggleButton,
boolean offsetPressedText)
images - the images to use. If null, simple gray images are created to fit the textfont - the font to use for rendering the text label. If null, the system font is used.offsetPressedText - Set to true to offset the button's text when the button is pressed.
|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||