# UIButton button component
# Overview
UIButton implements touch-based button functions.
# Instructions
The general button component depends on a UISprite component and a TouchInputComponent component.
var uiSpriteComponent = entity.addComponent(engine.UISprite);
var uiTouchInputComponent = entity.addComponent(engine.TouchInputComponent);
var uiButtonComponent = entity.addComponent(engine.UIButton);
# Component properties
Property name | Type | Default value | Description |
---|---|---|---|
normalColor | engine.Color | (Synchronize with UISprite) | Normal state color |
pressedColor | engine.Color | engine.Color.WHITE | Pressed state color |
disabledColor | engine.Color | engine.Color.WHITE | disabled state color |
transition | number | 0 | animation transition time |
normalSprite | engine.SpriteFrame | (Synchronize with UISprite) | Normal state image resource |
pressedSprite | engine.SpriteFrame | null | Pressed state image resource |
disabledSprite | engine.SpriteFrame | null | Disabled state image resource |
# method
setState(state: ButtonState, animation: boolean = true, forceUpdate: boolean = false)