Game Development Reference
In-Depth Information
} AxisBounds;
AxisBounds CreateAxisBounds(float lower, float
upper);
Here we can also define a helper method to make it a little easier to create the Ax-
isBounds structure.
class PointerAxisBoundsTrigger :
public Trigger
{
private:
bool _hasX, _hasY;
AxisBounds _x, _y;
KeyState _state, _expectedState;
bool IsWithinBounds(AxisBounds& b, float pt);
public:
virtual bool IsTriggered(InputManager *input);
void SetData(AxisBounds *xBounds, AxisBounds
*yBounds, KeyState expectedState);
};
This block of code defines the class, and you can see it is similar but it has an extra
helper to allow us to separate out the code checking if a provided pointer's point is
within the bounds.
bool
PointerAxisBoundsTrigger::IsWithinBounds(AxisBounds&
b, float pt)
{
return (pt > b.Lower) && (pt < b.Upper);
}
Search WWH ::




Custom Search