| Package | net.flashpunk |
| Class | public class Entity |
| Inheritance | Entity Tweener |
| Property | Defined by | ||
|---|---|---|---|
![]() | active : Boolean = true
If the Tweener should update.
| Tweener | |
![]() | autoClear : Boolean = false
If the Tweener should clear on removal.
| Tweener | |
| bottom : Number [read-only]
The bottommost position of the Entity's hitbox.
| Entity | ||
| centerX : Number [read-only]
The center x position of the Entity's hitbox.
| Entity | ||
| centerY : Number [read-only]
The center y position of the Entity's hitbox.
| Entity | ||
| collidable : Boolean = true
If the Entity should respond to collision checks.
| Entity | ||
| graphic : Graphic
Graphical component to render to the screen.
| Entity | ||
| halfHeight : Number [read-only]
Half the Entity's height.
| Entity | ||
| halfWidth : Number [read-only]
Half the Entity's width.
| Entity | ||
| height : int
Height of the Entity's hitbox.
| Entity | ||
| layer : int
The rendering layer of this Entity.
| Entity | ||
| left : Number [read-only]
The leftmost position of the Entity's hitbox.
| Entity | ||
| mask : Mask
An optional Mask component, used for specialized collision.
| Entity | ||
| name : String
The Entity's instance name.
| Entity | ||
| onCamera : Boolean [read-only]
If the Entity collides with the camera rectangle.
| Entity | ||
| originX : int
X origin of the Entity's hitbox.
| Entity | ||
| originY : int
Y origin of the Entity's hitbox.
| Entity | ||
| renderTarget : BitmapData
The BitmapData target to draw the Entity to.
| Entity | ||
| right : Number [read-only]
The rightmost position of the Entity's hitbox.
| Entity | ||
| top : Number [read-only]
The topmost position of the Entity's hitbox.
| Entity | ||
| type : String
The collision type, used for collision checking.
| Entity | ||
| visible : Boolean = true
If the Entity should render.
| Entity | ||
| width : int
Width of the Entity's hitbox.
| Entity | ||
| world : World
[read-only]
The World object this Entity has been added to.
| Entity | ||
| x : Number = 0
X position of the Entity in the World.
| Entity | ||
| y : Number = 0
Y position of the Entity in the World.
| Entity | ||
| Method | Defined by | ||
|---|---|---|---|
|
Constructor.
| Entity | ||
|
added():void
Override this, called when the Entity is added to a World.
| Entity | ||
|
Adds the graphic to the Entity via a Graphiclist.
| Entity | ||
![]() |
Adds a new Tween.
| Tweener | |
|
centerOrigin():void
Center's the Entity's origin (half width & height).
| Entity | ||
|
clampHorizontal(left:Number, right:Number, padding:Number = 0):void
Clamps the Entity's hitbox on the x-axis.
| Entity | ||
|
clampVertical(top:Number, bottom:Number, padding:Number = 0):void
Clamps the Entity's hitbox on the y axis.
| Entity | ||
![]() |
clearTweens():void
Removes all Tweens.
| Tweener | |
|
Checks for a collision against an Entity type.
| Entity | ||
|
collideInto(type:String, x:Number, y:Number, array:Object):void
Populates an array with all collided Entities of a type.
| Entity | ||
|
collidePoint(x:Number, y:Number, pX:Number, pY:Number):Boolean
Checks if this Entity overlaps the specified position.
| Entity | ||
|
collideRect(x:Number, y:Number, rX:Number, rY:Number, rWidth:Number, rHeight:Number):Boolean
Checks if this Entity overlaps the specified rectangle.
| Entity | ||
|
collideTypes(types:Object, x:Number, y:Number):Entity
Checks for collision against multiple Entity types.
| Entity | ||
|
collideTypesInto(types:Object, x:Number, y:Number, array:Object):void
Populates an array with all collided Entities of multiple types.
| Entity | ||
|
Checks if this Entity collides with a specific Entity.
| Entity | ||
|
distanceFrom(e:Entity, useHitboxes:Boolean = false):Number
Calculates the distance from another Entity.
| Entity | ||
|
distanceToPoint(px:Number, py:Number, useHitbox:Boolean = false):Number
Calculates the distance from this Entity to the point.
| Entity | ||
|
distanceToRect(rx:Number, ry:Number, rwidth:Number, rheight:Number):Number
Calculates the distance from this Entity to the rectangle.
| Entity | ||
|
getClass():Class
| Entity | ||
|
moveBy(x:Number, y:Number, solidType:Object = null, sweep:Boolean = false):void
Moves the Entity by the amount, retaining integer values for its x and y.
| Entity | ||
|
moveCollideX(e:Entity):Boolean
When you collide with an Entity on the x-axis with moveTo() or moveBy().
| Entity | ||
|
moveCollideY(e:Entity):Boolean
When you collide with an Entity on the y-axis with moveTo() or moveBy().
| Entity | ||
|
moveTo(x:Number, y:Number, solidType:Object = null, sweep:Boolean = false):void
Moves the Entity to the position, retaining integer values for its x and y.
| Entity | ||
|
moveTowards(x:Number, y:Number, amount:Number, solidType:Object = null, sweep:Boolean = false):void
Moves towards the target position, retaining integer values for its x and y.
| Entity | ||
|
removed():void
Override this, called when the Entity is removed from a World.
| Entity | ||
![]() |
Removes a Tween.
| Tweener | |
|
render():void
Renders the Entity.
| Entity | ||
|
setHitbox(width:int = 0, height:int = 0, originX:int = 0, originY:int = 0):void
Sets the Entity's hitbox properties.
| Entity | ||
|
setHitboxTo(o:Object):void
Sets the Entity's hitbox to match that of the provided object.
| Entity | ||
|
setOrigin(x:int = 0, y:int = 0):void
Sets the origin of the Entity.
| Entity | ||
|
toString():String
Gets the class name as a string.
| Entity | ||
|
update():void
Updates the Entity.
| Entity | ||
![]() |
updateTweens():void
Updates all contained tweens.
| Tweener | |
| bottom | property |
bottom:Number [read-only]The bottommost position of the Entity's hitbox.
Implementation public function get bottom():Number
| centerX | property |
centerX:Number [read-only]The center x position of the Entity's hitbox.
Implementation public function get centerX():Number
| centerY | property |
centerY:Number [read-only]The center y position of the Entity's hitbox.
Implementation public function get centerY():Number
| collidable | property |
public var collidable:Boolean = trueIf the Entity should respond to collision checks.
| graphic | property |
graphic:Graphic [read-write]Graphical component to render to the screen.
Implementation public function get graphic():Graphic
public function set graphic(value:Graphic):void
| halfHeight | property |
halfHeight:Number [read-only]Half the Entity's height.
Implementation public function get halfHeight():Number
| halfWidth | property |
halfWidth:Number [read-only]Half the Entity's width.
Implementation public function get halfWidth():Number
| height | property |
public var height:intHeight of the Entity's hitbox.
| layer | property |
layer:int [read-write]The rendering layer of this Entity. Higher layers are rendered first.
Implementation public function get layer():int
public function set layer(value:int):void
| left | property |
left:Number [read-only]The leftmost position of the Entity's hitbox.
Implementation public function get left():Number
| mask | property |
mask:Mask [read-write]An optional Mask component, used for specialized collision. If this is not assigned, collision checks will use the Entity's hitbox by default.
Implementation public function get mask():Mask
public function set mask(value:Mask):void
| name | property |
name:String [read-write]The Entity's instance name. Use this to uniquely identify single game Entities, which can then be looked-up with World.getInstance().
Implementation public function get name():String
public function set name(value:String):void
| onCamera | property |
onCamera:Boolean [read-only]If the Entity collides with the camera rectangle.
Implementation public function get onCamera():Boolean
| originX | property |
public var originX:intX origin of the Entity's hitbox.
| originY | property |
public var originY:intY origin of the Entity's hitbox.
| renderTarget | property |
public var renderTarget:BitmapDataThe BitmapData target to draw the Entity to. Leave as null to render to the current screen buffer (default).
| right | property |
right:Number [read-only]The rightmost position of the Entity's hitbox.
Implementation public function get right():Number
| top | property |
top:Number [read-only]The topmost position of the Entity's hitbox.
Implementation public function get top():Number
| type | property |
type:String [read-write]The collision type, used for collision checking.
Implementation public function get type():String
public function set type(value:String):void
| visible | property |
public var visible:Boolean = trueIf the Entity should render.
| width | property |
public var width:intWidth of the Entity's hitbox.
| world | property |
world:World [read-only]The World object this Entity has been added to.
Implementation public function get world():World
| x | property |
public var x:Number = 0X position of the Entity in the World.
| y | property |
public var y:Number = 0Y position of the Entity in the World.
| Entity | () | constructor |
public function Entity(x:Number = 0, y:Number = 0, graphic:Graphic = null, mask:Mask = null)Constructor. Can be usd to place the Entity and assign a graphic and mask.
Parametersx:Number (default = 0) — X position to place the Entity.
|
|
y:Number (default = 0) — Y position to place the Entity.
|
|
graphic:Graphic (default = null) — Graphic to assign to the Entity.
|
|
mask:Mask (default = null) — Mask to assign to the Entity.
|
| added | () | method |
public function added():voidOverride this, called when the Entity is added to a World.
| addGraphic | () | method |
public function addGraphic(g:Graphic):GraphicAdds the graphic to the Entity via a Graphiclist.
Parametersg:Graphic — Graphic to add.
|
Graphic |
| centerOrigin | () | method |
public function centerOrigin():voidCenter's the Entity's origin (half width & height).
| clampHorizontal | () | method |
public function clampHorizontal(left:Number, right:Number, padding:Number = 0):voidClamps the Entity's hitbox on the x-axis.
Parametersleft:Number — Left bounds.
|
|
right:Number — Right bounds.
|
|
padding:Number (default = 0) — Optional padding on the clamp.
|
| clampVertical | () | method |
public function clampVertical(top:Number, bottom:Number, padding:Number = 0):voidClamps the Entity's hitbox on the y axis.
Parameterstop:Number — Min bounds.
|
|
bottom:Number — Max bounds.
|
|
padding:Number (default = 0) — Optional padding on the clamp.
|
| collide | () | method |
public function collide(type:String, x:Number, y:Number):EntityChecks for a collision against an Entity type.
Parameterstype:String — The Entity type to check for.
|
|
x:Number — Virtual x position to place this Entity.
|
|
y:Number — Virtual y position to place this Entity.
|
Entity —
The first Entity collided with, or null if none were collided.
|
| collideInto | () | method |
public function collideInto(type:String, x:Number, y:Number, array:Object):voidPopulates an array with all collided Entities of a type.
Parameterstype:String — The Entity type to check for.
|
|
x:Number — Virtual x position to place this Entity.
|
|
y:Number — Virtual y position to place this Entity.
|
|
array:Object — The Array or Vector object to populate.
|
| collidePoint | () | method |
public function collidePoint(x:Number, y:Number, pX:Number, pY:Number):BooleanChecks if this Entity overlaps the specified position.
Parametersx:Number — Virtual x position to place this Entity.
|
|
y:Number — Virtual y position to place this Entity.
|
|
pX:Number — X position.
|
|
pY:Number — Y position.
|
Boolean — If the Entity intersects with the position.
|
| collideRect | () | method |
public function collideRect(x:Number, y:Number, rX:Number, rY:Number, rWidth:Number, rHeight:Number):BooleanChecks if this Entity overlaps the specified rectangle.
Parametersx:Number — Virtual x position to place this Entity.
|
|
y:Number — Virtual y position to place this Entity.
|
|
rX:Number — X position of the rectangle.
|
|
rY:Number — Y position of the rectangle.
|
|
rWidth:Number — Width of the rectangle.
|
|
rHeight:Number — Height of the rectangle.
|
Boolean — If they overlap.
|
| collideTypes | () | method |
public function collideTypes(types:Object, x:Number, y:Number):EntityChecks for collision against multiple Entity types.
Parameterstypes:Object — An Array or Vector of Entity types to check for.
|
|
x:Number — Virtual x position to place this Entity.
|
|
y:Number — Virtual y position to place this Entity.
|
Entity —
The first Entity collided with, or null if none were collided.
|
| collideTypesInto | () | method |
public function collideTypesInto(types:Object, x:Number, y:Number, array:Object):voidPopulates an array with all collided Entities of multiple types.
Parameterstypes:Object — An array of Entity types to check for.
|
|
x:Number — Virtual x position to place this Entity.
|
|
y:Number — Virtual y position to place this Entity.
|
|
array:Object — The Array or Vector object to populate.
|
| collideWith | () | method |
public function collideWith(e:Entity, x:Number, y:Number):EntityChecks if this Entity collides with a specific Entity.
Parameterse:Entity — The Entity to collide against.
|
|
x:Number — Virtual x position to place this Entity.
|
|
y:Number — Virtual y position to place this Entity.
|
Entity —
The Entity if they overlap, or null if they don't.
|
| distanceFrom | () | method |
public function distanceFrom(e:Entity, useHitboxes:Boolean = false):NumberCalculates the distance from another Entity.
Parameterse:Entity — The other Entity.
|
|
useHitboxes:Boolean (default = false) — If hitboxes should be used to determine the distance. If not, the Entities' x/y positions are used.
|
Number — The distance.
|
| distanceToPoint | () | method |
public function distanceToPoint(px:Number, py:Number, useHitbox:Boolean = false):NumberCalculates the distance from this Entity to the point.
Parameterspx:Number — X position.
|
|
py:Number — Y position.
|
|
useHitbox:Boolean (default = false) — If hitboxes should be used to determine the distance. If not, the Entities' x/y positions are used.
|
Number — The distance.
|
| distanceToRect | () | method |
public function distanceToRect(rx:Number, ry:Number, rwidth:Number, rheight:Number):NumberCalculates the distance from this Entity to the rectangle.
Parametersrx:Number — X position of the rectangle.
|
|
ry:Number — Y position of the rectangle.
|
|
rwidth:Number — Width of the rectangle.
|
|
rheight:Number — Height of the rectangle.
|
Number — The distance.
|
| getClass | () | method |
public function getClass():Class
Returns
Class |
| moveBy | () | method |
public function moveBy(x:Number, y:Number, solidType:Object = null, sweep:Boolean = false):voidMoves the Entity by the amount, retaining integer values for its x and y.
Parametersx:Number — Horizontal offset.
|
|
y:Number — Vertical offset.
|
|
solidType:Object (default = null) — An optional collision type (or array of types) to stop flush against upon collision.
|
|
sweep:Boolean (default = false) — If sweeping should be used (prevents fast-moving objects from going through solidType).
|
| moveCollideX | () | method |
public function moveCollideX(e:Entity):BooleanWhen you collide with an Entity on the x-axis with moveTo() or moveBy().
Parameterse:Entity — The Entity you collided with.
|
Boolean |
| moveCollideY | () | method |
public function moveCollideY(e:Entity):BooleanWhen you collide with an Entity on the y-axis with moveTo() or moveBy().
Parameterse:Entity — The Entity you collided with.
|
Boolean |
| moveTo | () | method |
public function moveTo(x:Number, y:Number, solidType:Object = null, sweep:Boolean = false):voidMoves the Entity to the position, retaining integer values for its x and y.
Parametersx:Number — X position.
|
|
y:Number — Y position.
|
|
solidType:Object (default = null) — An optional collision type (or array of types) to stop flush against upon collision.
|
|
sweep:Boolean (default = false) — If sweeping should be used (prevents fast-moving objects from going through solidType).
|
| moveTowards | () | method |
public function moveTowards(x:Number, y:Number, amount:Number, solidType:Object = null, sweep:Boolean = false):voidMoves towards the target position, retaining integer values for its x and y.
Parametersx:Number — X target.
|
|
y:Number — Y target.
|
|
amount:Number — Amount to move.
|
|
solidType:Object (default = null) — An optional collision type (or array of types) to stop flush against upon collision.
|
|
sweep:Boolean (default = false) — If sweeping should be used (prevents fast-moving objects from going through solidType).
|
| removed | () | method |
public function removed():voidOverride this, called when the Entity is removed from a World.
| render | () | method |
public function render():voidRenders the Entity. If you override this for special behaviour, remember to call super.render() to render the Entity's graphic.
| setHitbox | () | method |
public function setHitbox(width:int = 0, height:int = 0, originX:int = 0, originY:int = 0):voidSets the Entity's hitbox properties.
Parameterswidth:int (default = 0) — Width of the hitbox.
|
|
height:int (default = 0) — Height of the hitbox.
|
|
originX:int (default = 0) — X origin of the hitbox.
|
|
originY:int (default = 0) — Y origin of the hitbox.
|
| setHitboxTo | () | method |
public function setHitboxTo(o:Object):voidSets the Entity's hitbox to match that of the provided object.
Parameterso:Object — The object defining the hitbox (eg. an Image or Rectangle).
|
| setOrigin | () | method |
public function setOrigin(x:int = 0, y:int = 0):voidSets the origin of the Entity.
Parametersx:int (default = 0) — X origin.
|
|
y:int (default = 0) — Y origin.
|
| toString | () | method |
public function toString():StringGets the class name as a string.
ReturnsString — A string representing the class name.
|
| update | () | method |
public override function update():voidUpdates the Entity.