ig.

UIInteractive

new UIInteractive()

Interactive ui element. Tip: Impact++ UIElements are meant to be used for simple user interfaces. If you need something complex, it is recommended that you use the DOM!

Author:
  • Collin Hover - collinhover.com
Source:
Example
// it is easy to create a clickable button
myButtonClass = ig.UIInteractive.extend({
     // override the activate method to do something special when button interacted with
     activateComplete: function ( entity ) {
         // call parent activate
         this.parent();
         // do some activation behavior
     },
     // and since interactive elements are toggled by default
     // you can also do something when deactivated
     deactivateComplete: function ( entity ) {
         this.parent();
         // do some deactivation behavior
     }
});
// keep in mind that the default method
// for interacting with ui elements
// is to toggle activate and deactivate
// but if you only want an interactive element to be activated
// i.e. tapping always activates instead of toggling
myElement.alwaysToggleActivate = true;
// to have an interactive element do something
// just hook into the activated or deactivated signals
myButton.onActivated.add( myCallback, myContext );
// one way this can be used is for player jumping
myButton.onActivated.add( myPlayer.jump, myPlayer );
// then when we activate the element
// it will cause the player to jump
// we could also use it for player abilities
myButton.onActivated.add( myPlayer.specialAbility.activate, myPlayer.specialAbility );
// it will execute the player's special ability
// you can add as many callbacks to the signals as you need

enabled :Boolean

Whether element is enabled and able to be activated/deactivated.

Default Value:
  • true
Source:

onActivated :ig.Signal

Signal dispatched when UI element activated.
- created on init.

Source:

onDeactivated :ig.Signal

Signal dispatched when UI element deactivated.
- created on init.

Source:

targetable

Interactive ui should be targetable.

Source:

activate()

Source:

activateComplete(entity)

Called automatically when activated successfully to dispatch ig.UIInteractive#onActivated.

Parameters:
Name Type Description
entity
Source:

cleanup()

Source:

deactivate()

Source:

deactivateComplete(entity)

Called automatically when deactivated successfully to dispatch ig.UIInteractive#onDeactivated.

Parameters:
Name Type Description
entity
Source:

disable()

Disables element.

Source:

enable()

Enables element.

Source:

initProperties()

Source:

initTypes()

Adds ig.EntityExtended.TYPE.INTERACTIVE type.

Source:

resetExtras()

Source:

setEnabled(enabled)

Sets element enabled state.

Parameters:
Name Type Argument Default Description
enabled Boolean <optional>
false whether enabled.
Source: