ig.

PlayerManager

new PlayerManager()

Manager / controller that translates all input into actions for an entity. IMPORTANT: you should use the manager to control your player character, which is created automatically as the game's ig.GameExtended#playerManager property.

Author:
  • Collin Hover - collinhover.com
Source:
Example
// the player manager will automatically manage the player character
// i.e. handle translating inputs into basic movements
// as long as the player character either:
// (a) extends the ig.Player abstract, or
// (b) can be found by the game's getPlayer method
// it is important to note that any managed entity
// should at least extend ig.Character, or define all the basic movement methods
// you can easily change the entity controlled by the player
ig.game.playerManager.manage( myOtherPlayerCharacter );
// you can swap back to the orignal player character easily
ig.game.playerManager.manage( myOriginalPlayerCharacter );
// you can stop managing a character just as easily
// (this method is called automatically when you manage a new character)
ig.game.playerManager.manageRelease( myOriginalPlayerCharacter );
// to have the camera automatically follow the managed entity
// set the user config's CAMERA.AUTO_FOLLOW_PLAYER
// or set the camera's autoFollowPlayer property directly
ig.game.camera.autoFollowPlayer = true;
// the player manager will check if it can control an entity before handling inputs
// which usually checks for paused and controllable states
// and these properties are usually handled automatically
// so unless you're doing something strange, you don't need to worry about them
// the player manager also allows the entity it manages to handle inputs
// to hook into this, either:
// (a) extend the ig.Player abstract and override the handleInputs method
myOriginalPlayerClass = ig.Player.extend({
     handleInput: function () {
         // special input handling here
         // then call parent
         this.parent():
     }
});
// (b) or make sure your entity has a handleInputs method
myOtherPlayerCharacter = ig.Character.extend({
     handleInput: function () {
         // special input handling here
     }
});

autoManagePlayer :Boolean

Whether to automatically manage player if within level. IMPORTANT: this only checks once when the level is first created and on each ig.Player#spawn!

Source:
See:

<readonly> entity :ig.EntityExtended

Entity to control / manage, ideally an entity that descends from ig.Character and not just a plain entity. IMPORTANT: do not set this property directly, use ig.PlayerManager#manage instead!

Default Value:
  • null
Source:

<readonly> entityFallback :ig.EntityExtended

Entity to fallback to control when ig.PlayerManager#entity does not exist. IMPORTANT: do not set this property directly, use ig.PlayerManager#manageFallback or ig.PlayerManager#managePlayer instead!

Default Value:
  • null
Source:

group :Bitflag|Number|String

Groups to merge into managed entity's ig.EntityExtended#group.

Source:

holdToMove :Boolean

Whether to allow touch/click and hold to be interpreted as movement.

Source:
See:

onManageStarted :ig.Signal

Signal dispatched whenever an entity becomes managed.
- created on init.

Source:

onManageStopped :ig.Signal

Signal dispatched whenever the managed entity is removed.
- created on init.

Source:

swipeToJump :Boolean

Whether to allow swipe up to be interpreted as jump.

Source:
See:

type :Bitflag|Number|String

Types to merge into managed entity's ig.EntityExtended#type.

Source:

zIndex :Number

Z index to merge into managed entity's ig.EntityExtended#zIndex.

Default Value:
  • 0
Source:

handleInput()

Handles input translation to basic movement, jumping, and climbing, and tries to call controlled entity's handleInput method.

Source:

highlightManaged()

Attempts to highlight managed entity if the entity has a "highlight" animation.

Source:

init(settings)

Initializes manager.

Parameters:
Name Type Description
settings Object settings that correspond to manager properties
Source:

isManagedControllable() → {Boolean}

Checks if an the currently managed entity can be controlled.

Source:
Returns:
{ Boolean } whether entity can be controlled.

manage(entity)

Manages an entity by calling ig.PlayerManager#manageStart if valid new entity, or ig.PlayerManager#manageRelease if no entity passed.

Parameters:
Name Type Argument Description
entity ig.EntityExtended <optional>
entity to start managing, or none if should stop managing.
Source:

manageFallback(entity)

Sets a fallback entity to manage when no other entities to manage.

Parameters:
Name Type Argument Description
entity ig.EntityExtended <optional>
entity to set as fallback
Source:

managePlayer()

Special case for managing player.

Source:

manageRelease(entity)

Releases management by calling ig.PlayerManager#manageStop if currently managing an entity.

Parameters:
Name Type Argument Description
entity ig.EntityExtended <optional>
entity to release, or if none passed releases currently managed entity.
Source:

manageReleaseFallback(entity)

Stops managing fallback entity.

Parameters:
Name Type Argument Description
entity ig.EntityExtended <optional>
entity to release, or if none passed releases fallback entity.
Source:

manageStart(entity)

Starts managing entity, attempts to call entity's "manageStart" method, and dispatches ig.PlayerManager#onManageStarted. IMPORTANT: do not call this method directly, use ig.PlayerManager#manage. It is okay to override this method.

Parameters:
Name Type Description
entity ig.EntityExtended entity to manage.
Source:

manageStop()

Stops managing entity, attempts to call entity's "manageStop" method, and dispatches ig.PlayerManager#onManageStopped. IMPORTANT: do not call this method directly, use ig.PlayerManager#manageRelease. It is okay to override this method.

Source:

ready()

Sets manager as ready. Called automatically at end of ig.GameExtended#buildLevel.

Source:

reset()

Resets manager.

Source:

update()

Updates and handles switching entities, inputs, etc.

Source: