C# Class PunkX.Entity

Main game Entity class updated by World.
Inheritance: Tweener, glue.IPosition
Mostra file Open project: RichardMarks/PunkX

Public Properties

Property Type Description
collidable System.Boolean
height int
originX int
originY int
userData Object
visible System.Boolean
width int

Public Methods

Method Description
Entity ( float x, float y, Graphic graphic = null, Mask mask = null ) : System

Constructor. Can be usd to place the Entity and assign a graphic and mask.

added ( ) : void

Override this, called when the Entity is added to a World.

centerOrigin ( ) : void

Center's the Entity's origin (half width & height).

collide ( String type, float x, float y ) : Entity

Checks for a collision against an Entity type.

collideInto ( string type, float x, float y, List array ) : void

Populates an array with all collided Entities of a type.

collidePoint ( float x, float y, float pX, float pY ) : System.Boolean

Checks if this Entity overlaps the specified position.

collideRect ( float x, float y, float rX, float rY, int rWidth, int rHeight ) : System.Boolean

Checks if this Entity overlaps the specified rectangle.

collideTypes ( List types, float x, float y ) : Entity

Checks for collision against multiple Entity types.

collideTypesInto ( List types, float x, float y, List array ) : void

Populates an array with all collided Entities of multiple types.

collideWith ( Entity e, float x, float y ) : Entity

Checks if this Entity collides with a specific Entity.

distanceFrom ( Entity e, System.Boolean useHitboxes = false ) : float

Calculates the distance from another Entity.

distanceToPoint ( float px, float py, System.Boolean useHitbox = false ) : float

Calculates the distance from this Entity to the point.

distanceToRect ( float rx, float ry, int rwidth, int rheight ) : float

Calculates the distance from this Entity to the rectangle.

removed ( ) : void

Override this, called when the Entity is removed from a World.

render ( ) : void

Renders the Entity. If you override this for special behaviour, remember to call super.render() to render the Entity's graphic.

setHitbox ( int width, int height, int originX, int originY ) : void

Sets the Entity's hitbox properties.

toString ( ) : string

Gets the class name as a string.

update ( ) : void

Method Details

Entity() public method

Constructor. Can be usd to place the Entity and assign a graphic and mask.
public Entity ( float x, float y, Graphic graphic = null, Mask mask = null ) : System
x float X position to place the Entity.
y float Y position to place the Entity.
graphic Graphic Graphic to assign to the Entity.
mask Mask Mask to assign to the Entity.
return System

added() public method

Override this, called when the Entity is added to a World.
public added ( ) : void
return void

centerOrigin() public method

Center's the Entity's origin (half width & height).
public centerOrigin ( ) : void
return void

collide() public method

Checks for a collision against an Entity type.
public collide ( String type, float x, float y ) : Entity
type String The Entity type to check for.
x float Virtual x position to place this Entity.
y float Virtual y position to place this Entity.
return Entity

collideInto() public method

Populates an array with all collided Entities of a type.
public collideInto ( string type, float x, float y, List array ) : void
type string The Entity type to check for.
x float Virtual x position to place this Entity.
y float Virtual y position to place this Entity.
array List The Array or Vector object to populate.
return void

collidePoint() public method

Checks if this Entity overlaps the specified position.
public collidePoint ( float x, float y, float pX, float pY ) : System.Boolean
x float Virtual x position to place this Entity.
y float Virtual y position to place this Entity.
pX float X position.
pY float Y position.
return System.Boolean

collideRect() public method

Checks if this Entity overlaps the specified rectangle.
public collideRect ( float x, float y, float rX, float rY, int rWidth, int rHeight ) : System.Boolean
x float Virtual x position to place this Entity.
y float Virtual y position to place this Entity.
rX float X position of the rectangle.
rY float Y position of the rectangle.
rWidth int Width of the rectangle.
rHeight int Height of the rectangle.
return System.Boolean

collideTypes() public method

Checks for collision against multiple Entity types.
public collideTypes ( List types, float x, float y ) : Entity
types List An Array or Vector of Entity types to check for.
x float Virtual x position to place this Entity.
y float Virtual y position to place this Entity.
return Entity

collideTypesInto() public method

Populates an array with all collided Entities of multiple types.
public collideTypesInto ( List types, float x, float y, List array ) : void
types List An array of Entity types to check for.
x float Virtual x position to place this Entity.
y float Virtual y position to place this Entity.
array List The Array or Vector object to populate.
return void

collideWith() public method

Checks if this Entity collides with a specific Entity.
public collideWith ( Entity e, float x, float y ) : Entity
e Entity The Entity to collide against.
x float Virtual x position to place this Entity.
y float Virtual y position to place this Entity.
return Entity

distanceFrom() public method

Calculates the distance from another Entity.
public distanceFrom ( Entity e, System.Boolean useHitboxes = false ) : float
e Entity The other Entity.
useHitboxes System.Boolean If hitboxes should be used to determine the distance. If not, the Entities' x/y positions are used.
return float

distanceToPoint() public method

Calculates the distance from this Entity to the point.
public distanceToPoint ( float px, float py, System.Boolean useHitbox = false ) : float
px float X position.
py float Y position.
useHitbox System.Boolean If hitboxes should be used to determine the distance. If not, the Entities' x/y positions are used.
return float

distanceToRect() public method

Calculates the distance from this Entity to the rectangle.
public distanceToRect ( float rx, float ry, int rwidth, int rheight ) : float
rx float X position of the rectangle.
ry float Y position of the rectangle.
rwidth int Width of the rectangle.
rheight int Height of the rectangle.
return float

removed() public method

Override this, called when the Entity is removed from a World.
public removed ( ) : void
return void

render() public method

Renders the Entity. If you override this for special behaviour, remember to call super.render() to render the Entity's graphic.
public render ( ) : void
return void

setHitbox() public method

Sets the Entity's hitbox properties.
public setHitbox ( int width, int height, int originX, int originY ) : void
width int Width of the hitbox.
height int Height of the hitbox.
originX int X origin of the hitbox.
originY int Y origin of the hitbox.
return void

toString() public method

Gets the class name as a string.
public toString ( ) : string
return string

update() public method

public update ( ) : void
return void

Property Details

collidable public_oe property

If the Entity should respond to collision checks.
public Boolean,System collidable
return System.Boolean

height public_oe property

Height of the Entity's hitbox.
public int height
return int

originX public_oe property

X origin of the Entity's hitbox.
public int originX
return int

originY public_oe property

Y origin of the Entity's hitbox.
public int originY
return int

userData public_oe property

lets the user store additional data in their entities without needing to create inherited classes
public Object userData
return Object

visible public_oe property

If the Entity should render.
public Boolean,System visible
return System.Boolean

width public_oe property

Width of the Entity's hitbox.
public int width
return int