#include <imagetree.h>
Public Types | |
ALWAYS_INSIDE_BOX = 0x01 | |
Hit the inside of a box, even if the box is not filled. | |
GET_ALL_HITS = 0x04 | |
Get every object hit, not just the first. | |
enum | { ALWAYS_INSIDE_BOX = 0x01, GET_ALL_HITS = 0x04 } |
Public Member Functions | |
KrImNode * | Root () |
Return the very base node of the tree. It is a KrImNode and never a more derived type. | |
void | AddNode (KrImNode *parent, KrImNode *addMe) |
Add a ImNode to the tree. | |
bool | DeleteNode (KrImNode *removeMe) |
Call this to delete a node and remove it from the tree. | |
KrImNode * | FindNodeById (int id) |
Find a ImNode by its id. | |
KrImNode * | FindNodeByName (const std::string &name) |
Find a ImNode by its name. | |
void | HitTest (int x, int y, KrImNode *startHere, int flags, std::vector< KrImage * > *outputArray, int *windowIndex) |
Given a point -- in screen coordinates -- determine what ImageNodes are under that point. | |
bool | CheckSiblingCollision (KrImNode *checkThis, std::vector< KrImage * > *outputArray, int window=0) |
Given a node, check if it collides with any of its own siblings. | |
bool | CheckChildCollision (KrImNode *checkThis, KrImNode *parent, std::vector< KrImage * > *outputArray, int window=0) |
Given a node "checkThis" and a parent, check if "checkThis" collides with any of the children of the parent. | |
bool | CheckAllCollision (KrImNode *checkThis, std::vector< KrImage * > *outputArray, int window=0) |
Given a node, check if it collides with anything in the Tree. | |
void | Walk () |
Flushes the cached state of the tree and makes it ready to draw. |
anonymous enum |
Add a ImNode to the tree.
The parent can be specified; if not, the root will be used. The node added -- 'addMe' -- is handed over by ownership. It will be deleted when the tree is deleted or DeleteNode is called.
Node children cannot directly be added. There is no KrImNode::AddChild function for instance; everything must be added through the tree.
bool KrImageTree::CheckAllCollision | ( | KrImNode * | checkThis, | |
std::vector< KrImage * > * | outputArray, | |||
int | window = 0 | |||
) |
Given a node, check if it collides with anything in the Tree.
Returns true if any collisions occur, and returns an array of everything collided with.
See KrImage::CheckCollision for a discussion of collision issues.
bool KrImageTree::CheckChildCollision | ( | KrImNode * | checkThis, | |
KrImNode * | parent, | |||
std::vector< KrImage * > * | outputArray, | |||
int | window = 0 | |||
) |
Given a node "checkThis" and a parent, check if "checkThis" collides with any of the children of the parent.
There does not need to be any relationship between "checkThis" and "parent".
Returns true if any collisions occur, and returns an array (outputArray) of all the KrImages collided with.
See KrImage::CheckCollision for a discussion of collision issues.
bool KrImageTree::CheckSiblingCollision | ( | KrImNode * | checkThis, | |
std::vector< KrImage * > * | outputArray, | |||
int | window = 0 | |||
) |
Given a node, check if it collides with any of its own siblings.
Returns true if any collisions occur, and returns an array (outputArray) of all the KrImages collided with.
See KrImage::CheckCollision for a discussion of collision issues.
bool KrImageTree::DeleteNode | ( | KrImNode * | removeMe | ) |
Call this to delete a node and remove it from the tree.
void KrImageTree::HitTest | ( | int | x, | |
int | y, | |||
KrImNode * | startHere, | |||
int | flags, | |||
std::vector< KrImage * > * | outputArray, | |||
int * | windowIndex | |||
) |
Given a point -- in screen coordinates -- determine what ImageNodes are under that point.
Note that only images have bounds and are drawn, so only images can be hit.
If 'startHere' is null the whole tree will be searched, else the search will cover 'startHere' and its children.
HitTest, by defualt, stops at the first non-transparent pixel it hits. There are flags to modify this behavior: