ig.

Camera

new Camera()

Camera object for following objects and controlling screen.

Author:
  • Collin Hover - collinhover.com
Source:

<readonly> atmosphere :Boolean

Whether camera is overlaying atmosphere ontop of game world.

Default Value:
  • false
Source:

atmosphereFadeDuration :Number

Duration of atmosphere fade.

Default Value:
  • 1000
Source:

<readonly> atmosphereOverlay :Object

Atmosphere overlay entity.
- created on first atmosphere add

Default Value:
  • null
Source:

atmosphereSettings :ig.EntityExtended

Atmosphere overlay settings that map directly to ig.UIOverlay settings.

Source:

autoFollowPlayer :Boolean

Whether camera should auto-follow player. IMPORTANT: this only checks once when the level is first created and on each ig.Player#spawn!

Source:
See:

boundsLevel :Object

Level bounds within which camera should stay when locking camera within level.
- calculated automatically on ig.GameExtended#buildLevel and ig.GameExtended#resize

Source:
See:

boundsTrap :Object

Bounds within which to stay relative to entity camera is following. Tip: this is otherwise known as a camera trap.

Source:
See:

boundsTrapAsPct :Boolean

Whether to automatically calculate ig.Camera#boundsTrap from percentages in ig.Camera#boundsTrapPct.

Source:
See:

boundsTrapPct :Object

Bounds, as a percentage of screen size between -0.5 and 0.5, within which to stay relative to entity camera is following. Tip: this is otherwise known as a camera trap.

Source:
See:

centerFirstFollow :Boolean

Whether camera should center first followed entity of a level.

Source:
See:

<readonly> changed :Boolean

Whether camera has been changed since last update.

Source:

entity :ig.EntityExtended

Entity camera is following.

Default Value:
  • null
Source:

entityFallback :ig.EntityExtended

Entity camera will automatically follow when nothing else to follow.

Default Value:
  • null
Source:

keepCentered :Boolean

Whether to always try to keep centered on entity camera is following. IMPORTANT: this will override ig.Camera#boundsTrap and ig.Camera#boundsTrapPct.

Source:

keepInsideLevel :Boolean

Whether to keep the camera locked inside the level, preventing black borders

Source:

lerp :Number

How quickly to interpolate to target camera location.

Source:
Example
// set to 1 to snap camera
camera.lerp = 1;
// set to 0.025 to move slowly and smoothly
camera.lerp = 0.025;

lightAmplification :Number

Multiplier to amplify lights when cutting them out from atmosphere.

Default Value:
  • 3
Source:

lightBaseOnly :Boolean

Whether to draw light base shape (i.e. circle) or with shadows included, when cutting lights out of atmosphere.
- be careful when using this with characters that cast shadows!

Default Value:
  • true
Source:

lightsCutout :Boolean

Whether to cut lights out of atmosphere.

Default Value:
  • true
Source:

onTransitioned :ig.Signal

Signal dispatched when camera finishes transitioning between entities to follow.
- created on init.

Source:

paused :Boolean

Whether camera is paused.

Default Value:
  • false
Source:

<readonly> screenLast :Object

Last position of screen.

Source:

shakeDuration :Number

Camera shake duration in seconds.

Default Value:
  • 2
Source:

shakeFunction :function

Camera shake value function.

Source:

shakeOffset :Vector2|Object

Camera shake value function.
- created on first shake

Source:

shakeStrength :Boolean

Camera shake strength.

Default Value:
  • 8
Source:

shakeTimer :ig.Timer

Camera shake timer.
- created on first shake

Source:

shaking :Boolean

Whether camera is shaking.

Source:

snapFirstFollow :Boolean

Whether camera should snap, instead of transition, to first followed entity of a level.

Source:
See:

transitionDistance :Number

Base distance to try to transition per duration.
- when set to -1, will not affect transition duration

Source:

transitionDuration :Number

Duration of transition when switching entities that camera is following.

Source:

transitionDurationMax :Number

Maximum duration of transition when switching entities that camera is following.

Source:

transitionDurationMin :Number

Minimum duration of transition when switching entities that camera is following.

Source:

<readonly> transitioning :Boolean

Whether camera is transitioning between entities to follow.

Source:

<readonly> transitioningCenter :Boolean

Whether camera is transitioning to the center.

Source:

<readonly> transitioningInstantly :Boolean

Whether camera is transitioning instantly.

Source:

<readonly> transitionPct :Number

Percent progress of transition.

Source:

addAtmosphere(duration, atmosphereSettings)

Creates and overlays atmosphere ontop of game world.

Parameters:
Name Type Argument Description
duration Number <optional>
duration of fade.
atmosphereSettings Object <optional>
settings for atmosphere.
Source:

follow(entity, snap, center)

Starts following an entity.

Parameters:
Name Type Argument Description
entity ig.EntityExtended entity to follow.
snap Boolean <optional>
whether to snap to entity instead of transitioning.
center Boolean <optional>
whether to center on entity.
Source:

followFallback(entity, snap, center)

Sets a fallback follow entity and follows if not following any other.

Parameters:
Name Type Argument Description
entity ig.EntityExtended <optional>
entity to follow.
snap Boolean <optional>
whether to snap to entity instead of transitioning.
center Boolean <optional>
whether to center on entity.
Source:

followPlayer(snap, center)

Gets player entity and follow it as fallback.

Parameters:
Name Type Argument Description
snap Boolean <optional>
whether to snap to entity instead of transitioning.
center Boolean <optional>
whether to center on entity.
Source:

followRespawnable(entity)

Special follow case for use with respawned entity that pauses and makes entity invulnerable until transition is complete.

Parameters:
Name Type Argument Description
entity ig.EntityExtended <optional>
entity to follow.
Source:

getBoundsLevel(map)

Calculates the bounds for the current level.

Parameters:
Name Type Argument Default Description
map ig.Map <optional>
ig.game.collisionMap map to use in defining boundaries
Source:

init(settings)

Initializes camera.

Parameters:
Name Type Description
settings Object settings for camera.
Source:

pause()

Pauses camera.

Source:

ready()

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

Source:

removeAtmosphere(duration)

Fades and removes atmosphere.

Parameters:
Name Type Argument Description
duration Number <optional>
duration of fade.
Source:

reset()

Resets camera and game screen, then unfollows current entity that camera is following.

Source:

resize()

Resizes camera.

Source:

shake()

Starts shaking camera to simulate an earthquake.

Source:

shakeStop()

Stops shaking camera.

Source:

toggleAtmosphere(duration, atmosphereSettings)

Toggles atmosphere.

Parameters:
Name Type Argument Description
duration Number <optional>
duration of fade.
atmosphereSettings Object <optional>
settings for atmosphere.
Source:

transitionComplete()

Called automatically when transition is completed.

Source:

unfollow()

Stops following and/or transitioning to an entity.

Source:

unfollowFallback()

Unsets follow fallback entity.

Source:

unpause()

Unpauses camera.

Source:

update()

Updates camera.

Source:

updateAtmosphere()

Updates atmosphere if camera changed or cutting lights out of atmosphere and lights changed.
- called automatically by camera's update.

Source:

updateFollow()

Updates a follow in progress.
- called automatically by camera's update.

Source:

updateShake()

Updates camera shake.

Source: