Otter  0.9.8.91
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.PixelCollider Class Reference

Collider that can use an image as a mask. This is not recommended to use for most cases as it can be pretty expensive to process. More...

Inherits Otter.Collider.

Public Member Functions

 PixelCollider (string source, params int[] tags)
 Creates a pixel collider. More...
 
 PixelCollider (Texture texture, params int[] tags)
 
 PixelCollider (string source, Enum tag, params Enum[] tags)
 
 PixelCollider (Texture texture, Enum tag, params Enum[] tags)
 
bool PixelAt (int x, int y)
 Check if a pixel is collidable at x, y. More...
 
bool PixelAt (int x, int y, float threshold)
 Check if a pixel is collidable at X, Y. More...
 
bool PixelAtRelative (int x, int y)
 Check if a pixel is collideable at X - Left, Y - Top. More...
 
bool PixelAtRelative (int x, int y, float threshold)
 Check if a pixel is collideable at X - Left, Y - Top. More...
 
bool PixelArea (int x, int y, int x2, int y2)
 Check if any pixels in the area defined by X, Y, X2, Y2 are collideable. More...
 
bool PixelArea (int x, int y, int x2, int y2, float threshold)
 Check if any pixels in the area defined by X, Y, X2, Y2 are collideable. More...
 
override void Render (Color color=null)
 Draw the collider for debug purposes. More...
 
- Public Member Functions inherited from Otter.Collider
bool Overlap (float x, float y, int px, int py)
 Checks for a collision with a specific point. More...
 
bool Overlap (float x, float y, params int[] tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, Collider c)
 Checks for a collision against a specific Collider and returns true or false. More...
 
bool Overlap (float x, float y, Entity e)
 Checks for a collision against a specific Entity and returns true or false. More...
 
bool Overlap (float x, float y, List< int > tags)
 Checks for a collision against a list of Collliders and returns true or false. More...
 
bool Overlap (float x, float y, params Enum[] tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, List< Enum > tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, List< Entity > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
bool Overlap< T > (float x, float y, List< T > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
Collider Collide (float x, float y, List< Entity > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
Collider Collide< T > (float x, float y, List< T > entities)
 
Collider Collide (float x, float y, params int[] tags)
 Checks for a collision against specified tags. More...
 
Collider Collide (float x, float y, params Enum[] tags)
 Checks for a collision against specified tags. More...
 
Collider Collide (float x, float y, Collider c)
 Checks for a collision with a specific collider. More...
 
Collider Collide (float x, float y, Entity e)
 Checks for a collision with a specific entity. More...
 
Collider Collide (float x, float y, List< int > tags)
 Checks for a collision with a list of tags. More...
 
Collider Collide (float x, float y, List< Enum > tags)
 Checks for a collision with a list of tags. More...
 
Entity CollideEntity (float x, float y, params int[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, params int[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, params Enum[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, params Enum[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, Entity e)
 Checks for a collision with a specific Entity and returns an Entity. More...
 
CollideEntity< T > (float x, float y, Entity e)
 Checks for a collision with a specific Entity and returns an Entity. More...
 
Entity CollideEntity (float x, float y, Collider c)
 Checks for a collision with a specific Collider and returns an Entity. More...
 
CollideEntity< T > (float x, float y, Collider c)
 Checks for a collision with a specific Collider and returns an Entity. More...
 
Entity CollideEntity (float x, float y, List< int > tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, List< int > tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, List< Entity > entities)
 Checks for a collision with a list of Entities and returns an Entity. More...
 
CollideEntity< T > (float x, float y, List< T > entities)
 Checks for a collision with a list of Entities and returns an Entity. More...
 
List< ColliderCollideList (float x, float y, params int[] tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, params Enum[] tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, List< Enum > tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, List< int > tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< EntityCollideEntities (float x, float y, params int[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, params Enum[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, List< Enum > tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, params int[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, params Enum[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, List< Enum > tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, List< T > entities)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, List< int > tags)
 Creates a list of entities that the Collider has collided with. More...
 
virtual void Added ()
 Callback for when the Collider has been added to an Entity. More...
 
virtual void Removed ()
 Callback for when the Collider has been removed from an Entity. More...
 
Collider AddTag (int tag)
 Add a new tag to the Collider. More...
 
Collider AddTag (params Enum[] tags)
 Add new tags to the Collider. More...
 
bool HasTag (params Enum[] tags)
 
bool HasTag (params int[] tags)
 
Collider AddTag (params int[] tags)
 Add new tags to the Collider. More...
 
Collider RemoveTag (int tag)
 Remove a tag from the Collider. More...
 
Collider RemoveTag (params int[] tags)
 Remove tags from the Collider. More...
 
Collider RemoveTag (params Enum[] tags)
 Remove tags from the Collider. More...
 
virtual void CenterOrigin ()
 Center the origin of the Collider. Based off of Width and Height. More...
 
void SetPosition (float x, float y)
 Set the positon of the Collider. More...
 
void SetPosition (Vector2 xy)
 Set the position of the Collider. More...
 
void SetOrigin (float x, float y)
 Set the origin of the Collider More...
 
void SetOrigin (Vector2 xy)
 Set the origin of the Collider. More...
 

Public Attributes

float Threshold = 0
 The amount of Alpha a pixel needs to exceed to register as a collision. If 0, any pixel with an alpha above 0 will register as collidable. More...
 
- Public Attributes inherited from Otter.Collider
float X
 The X position of the Collider relative to the Entity. More...
 
float Y
 The Y position of the Collider relative to the Entity. More...
 
float OriginX
 The OriginX of the Collider. More...
 
float OriginY
 The OriginY of the Collider. More...
 
Entity Entity
 The entity that this collider is parented to. More...
 
bool Collidable = true
 Determines if this collider is collidable. If false, it will not register collisions with other colliders, but can still check for collisions with other colliders. More...
 

Properties

byte[] Pixels [get]
 The byte array of pixels. More...
 
- Properties inherited from Otter.Collider
List< int > Tags [get, set]
 The tags that this Collider is registered with. More...
 
virtual float Width [get, set]
 The width of the Collider. More...
 
virtual float Height [get, set]
 The height of the Collider. More...
 
virtual float CenterX [get]
 The X position of the center of the Collider. More...
 
virtual float CenterY [get]
 The Y position of the center of the Collider. More...
 
virtual float Left [get]
 The X position of the left side of the Collider. More...
 
virtual float Right [get]
 The X position of the right side of the Collider. More...
 
virtual float Top [get]
 The Y position of the top of the Collider. More...
 
virtual float Bottom [get]
 The Y position of the bottom of the Collider. More...
 
float HalfHeight [get]
 Half of the Collider's height. More...
 
float HalfWidth [get]
 Half of the Collider's width. More...
 

Detailed Description

Collider that can use an image as a mask. This is not recommended to use for most cases as it can be pretty expensive to process.

Constructor & Destructor Documentation

Otter.PixelCollider.PixelCollider ( string  source,
params int[]  tags 
)

Creates a pixel collider.

Parameters
sourceThe source image to create the collider from.
tagsThe tags to register the collider with.

Member Function Documentation

bool Otter.PixelCollider.PixelArea ( int  x,
int  y,
int  x2,
int  y2 
)

Check if any pixels in the area defined by X, Y, X2, Y2 are collideable.

Parameters
xThe left of the area to check.
yThe top of the area to check.
x2The right of the area to check.
y2The bottom of the area to check.
Returns
True if the pixel collides.
bool Otter.PixelCollider.PixelArea ( int  x,
int  y,
int  x2,
int  y2,
float  threshold 
)

Check if any pixels in the area defined by X, Y, X2, Y2 are collideable.

Parameters
xThe left of the area to check.
yThe top of the area to check.
x2The right of the area to check.
y2The bottom of the area to check.
thresholdThe alpha threshold that should register a collision.
Returns
True if the pixel collides.
bool Otter.PixelCollider.PixelAt ( int  x,
int  y 
)

Check if a pixel is collidable at x, y.

Parameters
xThe X position of the pixel to check.
yThe Y position of the pixel to check.
Returns
True if the pixel collides.
bool Otter.PixelCollider.PixelAt ( int  x,
int  y,
float  threshold 
)

Check if a pixel is collidable at X, Y.

Parameters
xThe X position of the pixel to check.
yThe Y position of the pixel to check.
thresholdThe alpha threshold that should register a collision.
Returns
True if the pixel collides.
bool Otter.PixelCollider.PixelAtRelative ( int  x,
int  y 
)

Check if a pixel is collideable at X - Left, Y - Top.

Parameters
xThe X position of the pixel to check.
yThe Y position of the pixel to check.
Returns
True if the pixel collides.
bool Otter.PixelCollider.PixelAtRelative ( int  x,
int  y,
float  threshold 
)

Check if a pixel is collideable at X - Left, Y - Top.

Parameters
xThe X position of the pixel to check.
yThe Y position of the pixel to check.
thresholdThe alpha threshold that should register a collision.
Returns
True if the pixel collides.
override void Otter.PixelCollider.Render ( Color  color = null)
virtual

Draw the collider for debug purposes.

Reimplemented from Otter.Collider.

Member Data Documentation

float Otter.PixelCollider.Threshold = 0

The amount of Alpha a pixel needs to exceed to register as a collision. If 0, any pixel with an alpha above 0 will register as collidable.

Property Documentation

byte [] Otter.PixelCollider.Pixels
get

The byte array of pixels.


The documentation for this class was generated from the following file: