Name | Type | Attributes | Description |
---|---|---|---|
views |
Array<Container | string> |
<optional> |
Array of views or textures that will be switching. |
triggerEvents |
ButtonEvent | ButtonEvent[] |
<optional> |
Button events, to switch views (can be one event or an array of events). |
activeViewID |
number |
<optional> |
The id of the view, visible by default. |
Example
// switch on onPress
const switch = new Swich([`switch_off.png`, `switch_on.png`]);
// switch on hover
const button = new Swich([`button_default.png`, `button_hover.png`], ['onHover', 'onOut']);
button.events.onPress.connect(() => console.log('button pressed'));
Extends
- Container
Members
Sets the id of the visible(active) view and shows to it.
Gets the id of the visible(active) view.
Returns the active view.
Container that holds all the content of the component.
Fired when active view changes.
Sets a list of events that will make a switcher switch to the next view.
Returns a list of events that will make a switcher switch to the next view.
Sets the list of instances for switching.
Returns all the switchable views
The id of the visible(active) view.
Returns the id of the next view in order. Or undefined, if order is empty.
Methods
Adds view instance to a switching list.
Name | Type | Description |
---|---|---|
view |
Container | string |
Switches a view to a given one without triggering the onChange event.
Name | Type | Attributes | Description |
---|---|---|---|
id |
number |
<optional> |
optional id of the view to show. If not set, will switch to the next view. |
Removes view instance from a switching list by id.
Name | Type | Description |
---|---|---|
id |
number |
id of the view to remove. |
Show a view by id, or to next one by order, if no ID provided.
Name | Type | Attributes | Description |
---|---|---|---|
id |
number |
<optional> |
optional id of the view to show. If not set, will switch to the next view. |