Skip to content
This repository was archived by the owner on Dec 6, 2022. It is now read-only.

Entity API

Ian Glen edited this page Aug 17, 2013 · 18 revisions

scripts/entity/core.js

This API is used to define objects that are fixed to the grid, such as buildings, topographical features, etc. Each entity type is a subclass of the Entity class.

You might want to check out Creating Entities and Creating Isometric Graphics.

Entity object

Used to define a generic entity on the grid.

var entity = new Entity(name, image, point, grid, topographic, visible)

Methods

Entity.draw()

Draws the Entity on the grid if Entity.visible is true.

Entity.getWidth()

Returns: (float) width of entity's image

Entity.getHeight()

Returns: (float) height of entity's image

Properties

Entity.name (string)

A human readable name for the entity, e.g "Military Base".

Entity.image (Image object)

The image for the entity that will be drawn on the grid.

Entity.grid (Grid)

The grid on which the entity exists.

Entity.point (IsometricPoint)

The location of the entity on the grid.

Entity.topographic (boolean)

Whether or not the entity is a topographical feature.

Entity.visible (boolean)

Whether or not the entity is to be drawn on the grid.

Static Methods

Methods that only exist in the class and are not added to new objects.

Entity.drawEntities()

Runs Entity.draw() for each visible entity in the Entity.entities array.

Entity.removeEntity(string name)

Removes an entity with given name from Entity.entities array.

Entity.getEntity(string name)

Returns: (Entity) entity with given name

Entity.getEntityAtPoint(IsometricPoint point)

Returns: (Entity) entity that exists at given point

Static Properties

Properties that only exist in the class and are not added to new objects.

Entity.entities (Array object)

An array of all the entities that have been created.

Clone this wiki locally