me.Entity(x, y, settings)

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 Attributes Default 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>
settings.width

width of a single frame in the given spritesheet

frameheight Number <optional>
settings.width

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)

Extends

Members

static alive :Boolean

dead/living state of the entity
default value : true

static body :me.Body

the entity body object

static id :Number

object unique ID (as defined in Tiled)

static renderable :me.Renderable

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

static type :String

object type (as defined in Tiled)

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn

Inherited From:
Default Value:
  • 1.0
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container|me.Entity

a reference to the parent object that contains this renderable

Inherited From:
Default Value:
  • undefined

Methods

static angleTo(entity) → {Number}

return the angle to the specified entity

Parameters:
Name Type Description
entity me.Entity

Entity

Returns:
Number -

angle in radians

static angleToPoint(vector) → {Number}

return the angle to the specified point

Parameters:
Name Type Description
vector me.Vector2d

vector

Returns:
Number -

angle in radians

static distanceTo(entity) → {Number}

return the distance to the specified entity

Parameters:
Name Type Description
entity me.Entity

Entity

Returns:
Number -

distance

static distanceToPoint(vector) → {Number}

return the distance to the specified point

Parameters:
Name Type Description
vector me.Vector2d

vector

Returns:
Number -

distance

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

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)

Returns:
Boolean -

true if the object should respond to the collision (its position and velocity will be corrected)

static onDeactivateEvent()

onDeactivateEvent Notification function
Called by engine before deleting the object