#include <image.h>
Inheritance diagram for KrImage::
Public Methods | |
virtual void | QueryBoundingBox (KrRect *boundingBox, int window)=0 |
Get the bounding box of the image, in its current state. More... | |
bool | CheckCollision (KrImage *other, int window=0) |
Check to see if this object collides with another object. More... | |
virtual KrImage * | ToImage () |
Return a pointer if this is an image. |
|
Check to see if this object collides with another object. Only Sprites and Canvases can collide. (Boxes, Tiles, etc. are ignored.) Composite Objects -- TextBox and Widgets -- are built on Sprites. Their components *will* collide. Something to be aware of. This is a pixel perfect (or near perfect, if scaled) 2D collision detection. 2D collision detection is a necessary -- but not sufficient -- collision criteria for 3D collision, if you are using an isometric view. For top down or side views, this is a complete detection scheme. See KrImageTree::CheckChildCollision and KrImageTree::CheckAllCollision for possibily more useful Tree variants of this call. The ImageTree must be in an consistent state in order to for collision checking to work. The function Engine()->Tree()->Walk() will bring the tree into a consistent state. The following operations will invalidate the state of the Tree, causing collision checking to fail:
Returns true if the objects collide. A window can be specified. Depending on the transformations appiled, collisions can be different per window. Collisions with scaled sprites and canvases is supported with one caveat: un-cached sprites can not be collision detected. For a full discussion of scaling, see the HTML docs. In brief, a scaled image can be cached (pre-calculated at a give x and y scale) or real time scaled. Real time scaled sprites can not be used in a collision test. |
|
Get the bounding box of the image, in its current state. If this is a sprite, it will be the bounding box of the current frame and action. The bounds are relative to the hotspot, so xmin and ymin will often be not zero. The current transformation matrix will be applied, so the result may be transformed bounds. |