Entity
class Entity extends Renderable
a Generic Object Entity
Constructor
new Entity(x: number, y: number, settings: object) → {}
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
boolean |
|
Body |
|
number |
|
Renderable |
|
string |
|
Methods from Entity
update the bounds when the body is modified |
|
onDeactivateEvent Notification function |
|
Bounds |
|
|
Properties inherited from Renderable
number |
|
boolean |
|
Container | Entity |
|
ObservableVector2d |
|
boolean |
|
string |
|
Matrix2d |
|
number |
|
boolean |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Rect | RoundRect | Polygon | Line | Ellipse |
|
string |
|
Function |
|
Application |
|
ObservableVector3d |
|
GLShader |
|
Color |
|
boolean |
|
Properties inherited from Rect
Methods inherited from Renderable
Methods inherited from Rect
Rect |
|
Rect |
|
boolean |
|
Rect |
|
boolean |
|
boolean |
|
boolean |
|
Rect |
|
Rect |
|
Polygon |
|
Rect |
|
Methods inherited from Polygon
Array<number> |
|
boolean |
|
Polygon |
|
Polygon |
|
|
|
Polygon |
|
Polygon |
|
Polygon |
|
Public Properties
alive: boolean = true
boolean
dead/living state of the entity
default value : true
renderable: Renderable
Renderable
The entity renderable component (can be any objects deriving from me.Renderable, like me.Sprite for example)
Public Methods
updateBounds(absolute: boolean) → {Bounds}
update the bounding box for this entity.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
absolute | boolean |
<optional> |
true |
update the bounds size and position in (world) absolute coordinates |
Type | Description |
---|---|
Bounds |
this entity bounding box Rectangle object |
Protected Methods
protected draw(renderer: CanvasRenderer | WebGLRenderer, viewport: Camera2d) → {}
draw this entity (automatically called by melonJS)
Name | Type | Attributes | Description |
---|---|---|---|
renderer | CanvasRenderer | WebGLRenderer |
a renderer instance |
|
viewport | Camera2d |
<optional> |
the viewport to (re)draw |