Annchienta::Mask Class Reference
Inherits
Annchienta::Cacheable.
Inherited by SwigDirector_Mask.
List of all members.
|
Public Member Functions |
bool | collision (int x1, int y1, Mask *mask2, int x2, int y2, bool box=false) |
void | fillRectangle (int x1, int y1, int x2, int y2, bool value) |
virtual CacheableType | getCacheableType () const |
int | getHeight () const |
int | getWidth () const |
| Mask (int w, int h) |
| Mask (const char *filename) |
virtual | ~Mask () |
Private Attributes |
int | height |
bool * | pixels |
int | width |
Detailed Description
Masks are basically 2d arrays of boolean values used for pixel-perfect collision detection.
Constructor & Destructor Documentation
Annchienta::Mask::Mask |
( |
const char * |
filename |
) |
|
Creates a new mask from a valid PNG image. This image should be as large as the sprite it is used for. Collision pixels should be white (rgb(255,255,255)) and ignore pixels should be black (rgb(0,0,0)).
- Parameters:
-
| filename | PNG image to load. |
Annchienta::Mask::Mask |
( |
int |
w, |
|
|
int |
h | |
|
) |
| | |
This creates a new mask with given dimensions. It will have the form of an isometric Tile by default, so you can directly use this to do tile collision.
- Parameters:
-
| w | Width for the new Mask. |
| h | Height for the new Mask. |
virtual Annchienta::Mask::~Mask |
( |
|
) |
[virtual] |
Member Function Documentation
bool Annchienta::Mask::collision |
( |
int |
x1, |
|
|
int |
y1, |
|
|
Mask * |
mask2, |
|
|
int |
x2, |
|
|
int |
y2, |
|
|
bool |
box = false | |
|
) |
| | |
Check if this Mask collides with another Mask.
- Parameters:
-
| x1 | X coordinate of this Mask. |
| y1 | Y coordinate of this Mask. |
| mask2 | The other mask to check collision with. |
| x2 | X coordinate of the other Mask. |
| y2 | Y coordinate of the other Mask. |
| box | When set to true, do a quick bounding box collision check instead of a pixel-perfect collision check. |
- Returns:
- If the two masks collide.
void Annchienta::Mask::fillRectangle |
( |
int |
x1, |
|
|
int |
y1, |
|
|
int |
x2, |
|
|
int |
y2, |
|
|
bool |
value | |
|
) |
| | |
Use this to edit a mask. Fills a rectangle with a certain value.
- Parameters:
-
| x1 | Top left x coordinate of the rectangle. |
| y1 | Top left y coordinate of the rectangle. |
| x2 | Bottom right x coordinate of the rectangle. |
| y2 | Bottom right y coordinate of the rectangle. |
| value | Value to fill the rectangle with. True for collision, false for transparency. |
virtual CacheableType Annchienta::Mask::getCacheableType |
( |
|
) |
const [virtual] |
int Annchienta::Mask::getHeight |
( |
|
) |
const |
- Returns:
- The height of this mask.
int Annchienta::Mask::getWidth |
( |
|
) |
const |
- Returns:
- The width of this mask.
Member Data Documentation