Class: Entity

module:entity/Entity~ Entity


new Entity(x, y, key)

The Entity class is the base class for all game entities. It needs to have to following properties

  • Health (Upto the child class to define)
  • Weapon
  • Inventory @todo
  • Factions @todo

It also cannot step outside world bounds.

Parameters:
Name Type Description
x number

The x coordinate of Entity on the canvas

y number

The y coordinate of Entity on the canvas

key string

The key to the loaded spritesheet

Source:
See:
  • Phaser.Sprite

Members


direction

Direction initialized to down. Must be changed only when new direction is chosen.

Source:

direction

Direction initialized to down. Must be changed only when new direction is chosen.

Source:

reputation

Reputation and Gossip

Source:

reputation

Reputation and Gossip

Source:

speed

Miscellaneous attributes.

Source:

speed

Miscellaneous attributes.

Source:

state

States. State can be 'idling', 'walking', 'attacking'

Source:

state

States. State can be 'idling', 'walking', 'attacking'

Source:

type

Type and ID

Source:

type

Type and ID

Source:

weapon

Begin with no weapon.

Source:

weapon

Begin with no weapon.

Source:

Methods


learnInfo(rumor)

Parameters:
Name Type Description
rumor Object
Source:

learnInfo(rumor)

Parameters:
Name Type Description
rumor Object
Source:

moveInDirection(direction, sprint)

Method to move any Entity

The parameter direction has to be one of 'up', 'down', 'left' or 'right'.

Another option is to use:

  1. UP
  2. RIGHT
  3. DOWN
  4. LEFT
Parameters:
Name Type Description
direction string | number
sprint Boolean

Whether to sprint or not

Source:

moveInDirection(direction, sprint)

Method to move any Entity

The parameter direction has to be one of 'up', 'down', 'left' or 'right'.

Another option is to use:

  1. UP
  2. RIGHT
  3. DOWN
  4. LEFT
Parameters:
Name Type Description
direction string | number
sprint Boolean

Whether to sprint or not

Source:

setAnimations(frames)

Set the animations of the Entity.

Parameters:
Name Type Description
frames object

Object containing the animation frames

Source:

setAnimations(frames)

Set the animations of the Entity.

Parameters:
Name Type Description
frames object

Object containing the animation frames

Source:

setDirection(direction)

Set the direction of the sprite

Parameters:
Name Type Description
direction string | number
Source:

setDirection(direction)

Set the direction of the sprite

Parameters:
Name Type Description
direction string | number
Source:

toString() → {string}

Return the Name of the function. This is a hack and should be used only for debugging.

Source:
Returns:
Type
string

toString() → {string}

Return the Name of the function. This is a hack and should be used only for debugging.

Source:
Returns:
Type
string

trueXY() → {Object}

Get the center of the Hitbox of the entity

Source:
Returns:
  • Point with x and y
Type
Object

trueXY() → {Object}

Get the center of the Hitbox of the entity

Source:
Returns:
  • Point with x and y
Type
Object

Class: Entity

module:entity/Entity~ Entity


new Entity(x, y, key)

The Entity class is the base class for all game entities. It needs to have to following properties

  • Health (Upto the child class to define)
  • Weapon
  • Inventory @todo
  • Factions @todo

It also cannot step outside world bounds.

Parameters:
Name Type Description
x number

The x coordinate of Entity on the canvas

y number

The y coordinate of Entity on the canvas

key string

The key to the loaded spritesheet

Source:
See:
  • Phaser.Sprite

Members


direction

Direction initialized to down. Must be changed only when new direction is chosen.

Source:

direction

Direction initialized to down. Must be changed only when new direction is chosen.

Source:

reputation

Reputation and Gossip

Source:

reputation

Reputation and Gossip

Source:

speed

Miscellaneous attributes.

Source:

speed

Miscellaneous attributes.

Source:

state

States. State can be 'idling', 'walking', 'attacking'

Source:

state

States. State can be 'idling', 'walking', 'attacking'

Source:

type

Type and ID

Source:

type

Type and ID

Source:

weapon

Begin with no weapon.

Source:

weapon

Begin with no weapon.

Source:

Methods


learnInfo(rumor)

Parameters:
Name Type Description
rumor Object
Source:

learnInfo(rumor)

Parameters:
Name Type Description
rumor Object
Source:

moveInDirection(direction, sprint)

Method to move any Entity

The parameter direction has to be one of 'up', 'down', 'left' or 'right'.

Another option is to use:

  1. UP
  2. RIGHT
  3. DOWN
  4. LEFT
Parameters:
Name Type Description
direction string | number
sprint Boolean

Whether to sprint or not

Source:

moveInDirection(direction, sprint)

Method to move any Entity

The parameter direction has to be one of 'up', 'down', 'left' or 'right'.

Another option is to use:

  1. UP
  2. RIGHT
  3. DOWN
  4. LEFT
Parameters:
Name Type Description
direction string | number
sprint Boolean

Whether to sprint or not

Source:

setAnimations(frames)

Set the animations of the Entity.

Parameters:
Name Type Description
frames object

Object containing the animation frames

Source:

setAnimations(frames)

Set the animations of the Entity.

Parameters:
Name Type Description
frames object

Object containing the animation frames

Source:

setDirection(direction)

Set the direction of the sprite

Parameters:
Name Type Description
direction string | number
Source:

setDirection(direction)

Set the direction of the sprite

Parameters:
Name Type Description
direction string | number
Source:

toString() → {string}

Return the Name of the function. This is a hack and should be used only for debugging.

Source:
Returns:
Type
string

toString() → {string}

Return the Name of the function. This is a hack and should be used only for debugging.

Source:
Returns:
Type
string

trueXY() → {Object}

Get the center of the Hitbox of the entity

Source:
Returns:
  • Point with x and y
Type
Object

trueXY() → {Object}

Get the center of the Hitbox of the entity

Source:
Returns:
  • Point with x and y
Type
Object