Class: Entity

me. Entity

new Entity(x, y, settings)

a Generic Object Entity
Parameters:
Name Type 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
Properties
Name Type Argument Description
width Number the physical width the entity takes up in game
height Number the physical height the entity takes up in game
name String <optional>
object entity name
id String <optional>
object unique IDs
image Image | String <optional>
resource name of a spritesheet to use for the entity renderable component
framewidth Number <optional>
width of a single frame in the given spritesheet
frameheight Number <optional>
height of a single frame in the given spritesheet
type String <optional>
object type
collisionMask Number <optional>
Mask collision detection for this object
shapes Array.<me.Rect> | Array.<me.Polygon> | Array.<me.Line> | Array.<me.Ellipse> <optional>
the initial list of collision shapes (usually populated through Tiled)
Source:
entity.js, line 31

Extends

Classes

Error

Members

<static> alive :Boolean

dead/living state of the entity
default value : true
Type:
  • Boolean
Source:
entity.js, line 97

<static> body :me.Body

the entity body object
Type:
Source:
entity.js, line 107

<static> id :Number

object unique ID (as defined in Tiled)
Type:
  • Number
Source:
entity.js, line 88

<static> name :String

Entity name
as defined in the Tiled Object Properties
Type:
  • String
Source:
entity.js, line 69

<static> renderable :me.Renderable

The entity renderable component (can be any objects deriving from me.Renderable, like me.Sprite for example)
Type:
Source:
entity.js, line 354

<static> type :String

object type (as defined in Tiled)
Type:
  • String
Source:
entity.js, line 79

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn
Type:
  • Number
Inherited From:
Default Value:
  • 1.0
Source:
renderable.js, line 180
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container|me.Entity

a reference to the parent object that contains this renderable, or undefined if it has not been added to one.
Type:
Inherited From:
Default Value:
  • undefined
Source:
renderable.js, line 192

Methods

<static> angleTo(entity) → {Number}

return the angle to the specified entity
Parameters:
Name Type Description
entity me.Entity Entity
Source:
entity.js, line 188
Returns:
angle in radians
Type
Number

<static> angleToPoint(vector) → {Number}

return the angle to the specified point
Parameters:
Name Type Description
vector me.Vector2d vector
Source:
entity.js, line 206
Returns:
angle in radians
Type
Number

<static> distanceTo(entity) → {Number}

return the distance to the specified entity
Parameters:
Name Type Description
entity me.Entity Entity
Source:
entity.js, line 153
Returns:
distance
Type
Number

<static> distanceToPoint(vector) → {Number}

return the distance to the specified point
Parameters:
Name Type Description
vector me.Vector2d vector
Source:
entity.js, line 171
Returns:
distance
Type
Number

<protected, static> draw(renderer, region)

object draw
not to be called by the end user
called by the game manager on each game loop
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer a renderer object
region me.Rect to draw
Source:
entity.js, line 285

<static> onCollision(response, other) → {Boolean}

onCollision callback
triggered in case of collision, when this entity body is being "touched" by another one
Parameters:
Name Type Description
response me.collision.ResponseObject the collision response object
other me.Entity the other entity touching this one (a reference to response.a or response.b)
Source:
entity.js, line 338
Returns:
true if the object should respond to the collision (its position and velocity will be corrected)
Type
Boolean

<static> onDeactivateEvent()

onDeactivateEvent Notification function
Called by engine before deleting the object
Source:
entity.js, line 325