ig.

AbilityShoot

new AbilityShoot()

Ability to shoot projectiles. For instant damage, use ig.AbilityDamage instead. 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
// shooting things is easy
// each character already has an abilities list
// which is a special hierarchy object
// that has built in methods to facilitate ability use
character.abilities = new ig.Hierarchy();
// but this abilities list is empty
// so create a new shoot ability
// and don't forget to pass the entity
// so the ability has a reference to its user
character.shoot = new ig.AbilityShoot( character );
// unlike some other abilities
// the shoot ability won't work out of the box
// it needs a projectile entity class
// so lets make a new one
ig.EntityBullet = ig.global.EntityBullet = ig.Projectile.extend({
     size: { x: 10, y: 6 },
     animSheet: new ig.AnimationSheet( ig.CONFIG.PATH_TO_MEDIA + 'bullet.png', 10, 6),
     damage: 10
});
// and set it as our shoot ability's spawningEntity
character.shoot.spawningEntity = ig.EntityBullet;
// then, optionally, add the ability
// to the character's ability list
character.abilities.addDescendant( character.shoot );
// now when our character needs to get violent
// and really shoot something
character.shoot.activate();
// but we also want to control where the bullet fires
var shootSettings = { offsetX: -10, offsetY: 0 };
// it can accelerate towards our offset
character.shoot.offsetAccelX = 1;
character.shoot.offsetAccelY = 1;
// it can also start with a velocity towards our offset
character.shoot.offsetVelX = 1;
character.shoot.offsetVelY = 1;
// and now, when we shoot, the projectile
// should go towards the left
character.shoot.activate( shootSettings );
// or instead of defining the offset in the settings
// we can give the ability the player's tapping input
// and it will figure out the offset direction for us
// so lets get all input points that have tapped
var inputPoints = ig.input.getInputPoints([ 'tapped' ], [ true ]);
// for the example, use only the first
var inputPoint = inputPoints[ 0 ];
if ( inputPoint ) {
     // and give it to the shoot ability
     character.shoot.activate(inputPoint);
}
// in the case of the player
// if you want the shoot to automatically work with tapping
// in other words, you won't need to bother with input points
// just set the ability type to spammable (don't forget to require ig.utils)
ig.AbilityShootThings = ig.AbilityShoot.extend({
     initTypes: function () {
         this.parent();
         ig.utils.addType(ig.Ability, this, 'type', "SPAMMABLE");
     }
});

activateCastSettings

Cast activate by animation 'shoot' while moving.

Source:

movable

Ability can be done while moving.

Default Value:
  • true
Source:

offsetAccelX :Number

Horizontal acceleration of projectile in offset direction.

Default Value:
  • 0
Source:

offsetAccelY :Number

Vertical acceleration of projectile in offset direction.

Default Value:
  • 0
Source:

offsetVelX :Number

Horizontal velocity of projectile in offset direction.

Default Value:
  • 0
Source:

offsetVelY :Number

Vertical velocity of projectile in offset direction.

Default Value:
  • 0
Source:

relativeVelPctX :Number

Percent user's horizontal velocity to add to projectile, where 1 = 100%.

Default Value:
  • 0
Source:

relativeVelPctY :Number

Percent user's vertical velocity to add to projectile, where 1 = 100%.

Default Value:
  • 0
Source:

shootLocationMaxPctX :Number

Maximum position on y axis, as a percent from 0 to 1, from left of entity that a projectile can be fired from.

Default Value:
  • 1
Source:

shootLocationMaxPctY :Number

Maximum position on x axis, as a percent from 0 to 1, from top of entity that a projectile can be fired from.

Source:

shootLocationMinPctX :Number

Minimum position on y axis, as a percent from 0 to 1, from left of entity that a projectile can be fired from.

Default Value:
  • 0
Source:

shootLocationMinPctY :Number

Minimum position on x axis, as a percent from 0 to 1, from top of entity that a projectile can be fired from.

Source:

spawnAtTarget :Boolean

Whether to spawn at entity or at target position.

Default Value:
  • false
Source:

spawningEntity :String|ig.EntityExtended

Type of projectile to spawn.

Source:

activateComplete(settings)

Creates projectile and handles application of settings.

Parameters:
Name Type Description
settings Object settings object.
Source:

clone()

Source: