Button
Function | Description |
---|---|
activate() |
Triggers the action assigned to the button as if it was tapped. |
isVisible() |
Returns true if the Button is visible, false if not. If a Button is not visible it cannot be tapped. |
onClick |
Function assigned to this property will be executed when user touches the button. |
opacity() |
Returns the opacity of the button. |
position() |
Returns position of the button. |
rotation() |
Returns the rotation of the button. |
scale() |
Returns the scale of the button. |
setOpacity(value) |
Sets the opacity of a button. Note: Setting the opacity to 0 will make the button invisible, but still tappable. If you’d like to hide a button entirely, use setVisible(false). |
setPosition(value) |
Sets the screen position of the button. |
setRotation(value) |
Sets the 2D rotation of the button in degrees. |
setScale(value) |
Sets the 2D scale of the button. |
setVisible(value) |
Sets the visibility of a button. If a button is not visible, it cannot be tapped. If you’d like an invisible but tappable button, use setOpacity(0). |
activate()
Triggers the action assigned to the button as if it was tapped.
isVisible()
Returns true if the Button is visible, false if not. If a Button is not visible it cannot be tapped.
Returns
boolean true if the Button is visible, false if not
onClick
Function assigned to this property will be executed when user touches the button.
let button = this.ui().find('MyButton')[0]; button.onClick = function(){ Ads.showInterstitial(); }
opacity()
Returns the opacity of the button.
Returns
number the opacity of the button. Range: 0-255.
position()
Returns position of the button.
Returns
Vec3 {x, y, z} position of the button.
rotation()
Returns the rotation of the button.
Returns
Vec3 {x, y, z} rotation of the button.
scale()
Returns the scale of the button.
Returns
Vec {x, y, z} scale of the button.
setOpacity(value)
Sets the opacity of a button. Note: Setting the opacity to 0 will make the button invisible, but still tappable. If you’d like to hide a button entirely, use setVisible(false).
Parameters
number value – Range: 0-255. The lower the value, the less opaque the button becomes.
setPosition(value)
Sets the screen position of the button.
Parameters
Vec2 value – the {x, y} position
setRotation(value)
Sets the 2D rotation of the button in degrees.
Parameters
number value – the new rotation in degrees
setScale(value)
Sets the 2D scale of the button.
Parameters
Vec2 value – the {x, y} new scale
setVisible(value)
Sets the visibility of a button. If a button is not visible, it cannot be tapped. If you’d like an invisible but tappable button, use setOpacity(0).
Parameters
boolean value – true for visible, false for not visible.