Reference Source Test
public class | source

Entity

Direct Subclass:

Character, Chest, Item, Projectile

Indirect Subclass:

Mob, Npc, Player

Initialize a new entity:

Example:

const myEntity = new Entity(1, 'player');

Constructor Summary

Public Constructor
public

constructor(id: Number, kind: String, label: String)

Constructor to initialize a new entity

Member Summary

Public Members
public

Angle of the entity

public

[angled description]

public

Animations for the sprite

public

Timeout function for blinking

public

Count down time

public

Current counter

public

Critical health

public

Current animation the sprite should be playing

public

Set if the entity is dirty

public

Callback for when the entity is dirty

public

Whether or not this is fading

public

Fading time

public

Grid X position

public

Grid Y position

public

Handler for the entity

public

Has a counter

public

Hurt sprite name

public

Entity id

public

Label for the entity

public

Name of the entity

public

Non pathable

public

Normal sprite name

public

Path

public

CAllback function when the entity is ready

public

Rendering data

public

Has a shadow

public

Offset for the shadow on the Y axis

public

Sprite

public

Whether or not to flip the sprite on the X axis

public

Whether or not to flip the sprite on the Y axis

public

Whether or not the sprite has been loaded

public

Stunned status

public

Terror status

public

Wehther or not this entity is visible

public

X coordinate

public

Y coordinate

Method Summary

Public Methods
public

blink(speed: Number)

Tell this entity to start blinking

public

fadeIn(time: Number)

Tell this to fade in given the duration

public

Look for an animtions list for this specific animation given it's name

public

Get the distance from this entity to the given x,y coordinates

public

Get the distance from this entity to another entity

public

Returns the name of the sprite

public

Check if this entity currently has a path

public

Check whether or not this entity has a shadow

public

Returns the instance of the weapon this entity has

public

Figure out if this entity is within the attack radius of the given entity

public

Figure out if this entity is within the extended attack radius of the given entity

public

isPositionAdjacent(x: Number, y: Number, ignoreDiagonals: Boolean): Boolean

Checks to see if the x,y coordinate is adjacent to the entity's current position

public

Check whether or not this entity is visible

public

This is important for when the client is on a mobile screen.

public

onDirty(callback: Function)

When this entity's is dirty (mobile) use this callback

public

onReady(callback: Function)

When this entity's sprite is loaded trigger this callback

public

setAnimation(name: String, speed: Number, count: Number, onEndCount: Number)

Set the animation on this entity

public

Set the count for the count down time

public

Set the x,y position of the entity on the tile grid

public

setName(name: String)

Set the entity's name

public

setPosition(x: Number, y: [type])

Set the x,y position for the entity

public

setSprite(sprite: Sprite)

Set the sprite for this entity

public

setVisible(visible: Boolean)

Set the visibility on this entity

public

Tell the entity to stop blinking and force it to be visible

public

Toggle the current visibility of this entity

Public Constructors

public constructor(id: Number, kind: String, label: String) source

Constructor to initialize a new entity

Params:

NameTypeAttributeDescription
id Number

the entity id

kind String

the type of entity this is

label String

a name for the entity this is

Public Members

public angle: Number source

Angle of the entity

public angled: Boolean source

[angled description]

public animations: Animation source

Animations for the sprite

public blinking: Function source

Timeout function for blinking

public countdownTime: Number source

Count down time

public counter: Number source

Current counter

public critical: Boolean source

Critical health

public currentAnimation: String source

Current animation the sprite should be playing

public dirty: Boolean source

Set if the entity is dirty

public dirtyCallback: Function source

Callback for when the entity is dirty

public fading: Boolean source

Whether or not this is fading

public fadingTime: Number source

Fading time

public gridX: Number source

Grid X position

public gridY: Number source

Grid Y position

public handler: EntityHandler source

Handler for the entity

public hasCounter: Boolean source

Has a counter

public hurtSprite: String source

Hurt sprite name

public id: Number source

Entity id

public label: String source

Label for the entity

public name: String source

Name of the entity

public nonPathable: Boolean source

Non pathable

public normalSprite: String source

Normal sprite name

public path: Boolean source

Path

public readyCallback: Function source

CAllback function when the entity is ready

public renderingData: Object source

Rendering data

public shadow: Boolean source

Has a shadow

public shadowOffsetY: Number source

Offset for the shadow on the Y axis

public sprite: Sprite source

Sprite

public spriteFlipX: Boolean source

Whether or not to flip the sprite on the X axis

public spriteFlipY: Boolean source

Whether or not to flip the sprite on the Y axis

public spriteLoaded: Boolean source

Whether or not the sprite has been loaded

public stunned: Boolean source

Stunned status

public terror: Boolean source

Terror status

public visible: Boolean source

Wehther or not this entity is visible

public x: Number source

X coordinate

public y: Number source

Y coordinate

Public Methods

Tell this entity to start blinking

Params:

NameTypeAttributeDescription
speed Number

the interval time between blinks

public fadeIn(time: Number) source

Tell this to fade in given the duration

Params:

NameTypeAttributeDescription
time Number

the amount of time to fade in

public getAnimationByName(name: String): Animation | null source

Look for an animtions list for this specific animation given it's name

Params:

NameTypeAttributeDescription
name String

the name of the animation

Return:

Animation | null

returns the animation object or null if not found

public getCoordDistance(toX: Number, toY: Number): Number source

Get the distance from this entity to the given x,y coordinates

Params:

NameTypeAttributeDescription
toX Number

the x coordinate

toY Number

the y coordinate

Return:

Number

the further x or y distance to this coordinate

public getDistance(entity: Entity): Number source

Get the distance from this entity to another entity

Params:

NameTypeAttributeDescription
entity Entity

the entity you want to get the distance to

Return:

Number

the furtherst x or y distance from the given entity

public getSprite(): String source

Returns the name of the sprite

Return:

String

the name of the sprite

public hasPath(): Object source

Check if this entity currently has a path

Return:

Object

returns the entity's path

public hasShadow(): Object source

Check whether or not this entity has a shadow

Return:

Object

returns the entity's shadow

public hasWeapon(): Item | Projectile source

Returns the instance of the weapon this entity has

Return:

Item | Projectile

a weapon or projectile

public inAttackRadius(entity: Entity): Boolean source

Figure out if this entity is within the attack radius of the given entity

Params:

NameTypeAttributeDescription
entity Entity

Player|Mob|Character|NPC

Return:

Boolean

returns true if they are within the entity's attack radius, if the entity has no attack radius default to 2 grid cells

public inExtraAttackRadius(entity: Entity): Boolean source

Figure out if this entity is within the extended attack radius of the given entity

Params:

NameTypeAttributeDescription
entity Entity

Player|Mob|Character|NPC

Return:

Boolean

returns true if they are within the entity's attack radius, if the entity has no attack radius default to 3 grid cells

public isPositionAdjacent(x: Number, y: Number, ignoreDiagonals: Boolean): Boolean source

Checks to see if the x,y coordinate is adjacent to the entity's current position

Params:

NameTypeAttributeDescription
x Number

coordinate

y Number

coordinate

ignoreDiagonals Boolean

if true, will ignore diagonal directions, defaults to false (optional)

Return:

Boolean

public isVisible(): Boolean source

Check whether or not this entity is visible

Return:

Boolean

returns true if visibile

public loadDirty() source

This is important for when the client is on a mobile screen. So the sprite has to be handled differently.

public onDirty(callback: Function) source

When this entity's is dirty (mobile) use this callback

Params:

NameTypeAttributeDescription
callback Function

the function to call when the sprite isDirty

public onReady(callback: Function) source

When this entity's sprite is loaded trigger this callback

Params:

NameTypeAttributeDescription
callback Function

the function to call when the sprite is loaded

public setAnimation(name: String, speed: Number, count: Number, onEndCount: Number) source

Set the animation on this entity

Params:

NameTypeAttributeDescription
name String

the name of the animation

speed Number

the animation speed

count Number

how many times to play the animation

onEndCount Number

callback to trigger when the animation ends after count number of times

public setCountdown(count: Number) source

Set the count for the count down time

Params:

NameTypeAttributeDescription
count Number

sets the counter

public setGridPosition(x: Number, y: Number) source

Set the x,y position of the entity on the tile grid

Params:

NameTypeAttributeDescription
x Number

the gridX

y Number

the gridY

public setName(name: String) source

Set the entity's name

Params:

NameTypeAttributeDescription
name String

the name of this entity

public setPosition(x: Number, y: [type]) source

Set the x,y position for the entity

Params:

NameTypeAttributeDescription
x Number

the x position on the screen

y [type]

the y position on the screen

public setSprite(sprite: Sprite) source

Set the sprite for this entity

Params:

NameTypeAttributeDescription
sprite Sprite

the sprite for this entity

public setVisible(visible: Boolean) source

Set the visibility on this entity

Params:

NameTypeAttributeDescription
visible Boolean

true|false

public stopBlinking() source

Tell the entity to stop blinking and force it to be visible

public toggleVisibility() source

Toggle the current visibility of this entity