Entity

class Entity extends Renderable

a Generic Object Entity

Constructor


new Entity(x: number, y: number, settings: object) → {}
Parameters:
Name Type Attributes Default Description
x number

the x coordinates of the entity object

y number

the y coordinates of the entity object

settings object

Entity properties, to be defined through Tiled or when calling the entity constructor

settings.width number

the physical width the entity takes up in game

settings.height number

the physical height the entity takes up in game

settings.name string

<optional>

object entity name

settings.id string

<optional>

object unique IDs

settings.image Image | string

<optional>

resource name of a spritesheet to use for the entity renderable component

settings.anchorPoint Vector2d

<optional>

0.0

Entity anchor point

settings.framewidth number

<optional>

settings.width

width of a single frame in the given spritesheet

settings.frameheight number

<optional>

settings.width

height of a single frame in the given spritesheet

settings.type string

<optional>

object type

settings.collisionMask number

<optional>

Mask collision detection for this object

settings.shapes Array<Rect> | Array<Polygon> | Array<Line> | Array<Ellipse>

<optional>

the initial list of collision shapes (usually populated through Tiled)

Summary


Properties from Entity

Methods from Entity

onBodyUpdate()

update the bounds when the body is modified

onDeactivateEvent()

onDeactivateEvent Notification function

Bounds
updateBounds(absolute: boolean)
protected draw(renderer: CanvasRenderer | WebGLRenderer, viewport: Camera2d)

Properties inherited from Rect

number
bottom
number
centerX
number
centerY
number
height
number
left
number
right
number
top
number
width

Properties inherited from Polygon

Array<Vector2d>
points

Public Properties


alive entity.js:78
alive: boolean = true

boolean

dead/living state of the entity
default value : true

body entity.js:95
body: Body

Body

the entity body object

id entity.js:72
id: number

number

object unique ID (as defined in Tiled)

renderable entity.js:115
renderable: Renderable

Renderable

The entity renderable component (can be any objects deriving from me.Renderable, like me.Sprite for example)

type entity.js:66
type: string

string

object type (as defined in Tiled)

Public Methods


onBodyUpdate entity.js:175
onBodyUpdate() → {}

update the bounds when the body is modified

onDeactivateEvent entity.js:237
onDeactivateEvent() → {}

onDeactivateEvent Notification function

updateBounds entity.js:142
updateBounds(absolute: boolean) → {Bounds}

update the bounding box for this entity.

Parameters:
Name Type Attributes Default Description
absolute boolean

<optional>

true

update the bounds size and position in (world) absolute coordinates

Returns:
Type Description
Bounds

this entity bounding box Rectangle object

Protected Methods


draw entity.js:202
protected draw(renderer: CanvasRenderer | WebGLRenderer, viewport: Camera2d) → {}

draw this entity (automatically called by melonJS)

Parameters:
Name Type Attributes Description
renderer CanvasRenderer | WebGLRenderer

a renderer instance

viewport Camera2d

<optional>

the viewport to (re)draw


Powered by webdoc!