ig.

AbilityInteract

new AbilityInteract()

Ability for interacting with interactive entities such as switches, levers, doors, etc, only when close enough. Tip: interaction only works on entities with ig.EntityExtended#type of ig.EntityExtended.TYPE.INTERACTIVE. IMPORTANT: always use abilities by calling the ig.Ability#activate method, and if the ability ig.Ability#requiresTarget make sure it ig.Ability#canFindTarget or you supply one via ig.Ability#setEntityTarget or ig.Ability#setEntityTargetFirst!

Author:
  • Collin Hover - collinhover.com
Source:
Example
// the interact ability requires a target
// which can be set in a variety of ways
// we can have the player's interact find the closest target
player.abilityInteract.canFindTarget = true;
player.abilityInteract.activate();
// ( but this is probably not a good idea )
// we can use the ability on a specific target
player.abilityInteract.setEntityTarget( mySpecificTarget );
player.abilityInteract.activate();
// or, how about using the player's tap or click target
// get all input points that have tapped
var inputPoints = ig.input.getInputPoints([ 'tapped' ], [ true ]);
// for the example, use only the first input point
var inputPoint = inputPoints[ 0 ];
if ( inputPoint ) {
     // give the ability a list of targets under the tap
     // and let the ability choose the best
     player.abilityInteract.setEntityTargetFirst(inputPoint.targets);
     player.abilityInteract.activate();
}

canFindTarget :Boolean

Ability can't find target automatically.

Default Value:
  • false
Source:

canTargetSelf :Boolean

Ability can't target self.

Default Value:
  • false
Source:

rangeX :Number

Range is based on effective size of the base character.

Source:
See:

rangeY :Number

Range is based on effective size of the base character.

Source:
See:

requiresTarget :Boolean

Ability needs target.

Default Value:
  • true
Source:

activateComplete()

Source:

initTypes()

Initializes interact types.
- adds ig.Ability.TYPE.INTERACT to {@link ig.Ability#type}
- adds ig.EntityExtended.TYPE.INTERACTIVE to ig.Ability#typeTargetable

Source: