Module Entity

Main superclass for all the objects who wants to have a minimal effect or interaction with other objects inside the level map.

Example of Main Entities:
  • Player
  • Mobs
  • Bullets
  • Collectable items…

Class Entity

Entity:initialize (x, y, speed, state, sprites, animations, anchor, quadCollider, level) Initialize the object Entity .
Entity:delete () Class destructor
Entity:update (dt) Update stage.
Entity:draw () Draw stage.
Entity:updateTile () Update tile attribute.
Entity:move (x, y) Move Entity x and y amount of pixel.
Entity:moveAt (x, y) Set Entity in location referenciated in world location coordinates..
Entity:_changeState (newState) Change state to a new state.


Class Entity

Entity Class.
Entity:initialize (x, y, speed, state, sprites, animations, anchor, quadCollider, level)
Initialize the object Entity .

Never create an instance of this class!. It’s recomendable work with subclasses.

Parameters:

  • x world x coordinate
  • y world y coordinate
  • speed value px/second
  • state init name state of state machine
  • sprites Image object that contains SPRITES used in animations.
  • animations dictionary of animations created with anim8 by kikito, the key is the stateName+facingPosition
  • anchor {x,y} table that define the sprite anchor point.
  • quadCollider {x1,y1,x2,y2} table with two pair of coordinates.
  • level Level where the object belongs
Entity:delete ()
Class destructor
Entity:update (dt)
Update stage.

Parameters:

  • dt delta time
Entity:draw ()
Draw stage.
Entity:updateTile ()
Update tile attribute. Update tile to the current isometric grid position.
Entity:move (x, y)
Move Entity x and y amount of pixel.

Parameters:

  • x px to move in X coordinate
  • y px to move in Y coordinate
Entity:moveAt (x, y)
Set Entity in location referenciated in world location coordinates..

Parameters:

  • x world location x coordinate
  • y world location y
Entity:_changeState (newState)
Change state to a new state.

Parameters:

  • newState new state.
generated by LDoc 1.3.12