Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
manager/EAHitBox.cpp
- Committer:
- richardparker
- Date:
- 2010-03-31
- Revision:
- 3:24fbf4dbd7e5
- Parent:
- 1:f04bcaea1d60
File content as of revision 3:24fbf4dbd7e5:
#include "mbed.h"
#include "EAHitBox.h"
#include "EAHitHandler.h"
EAHitBox::EAHitBox()
: _next(NULL),
_handler(NULL),
_width(0),
_height(0),
_x(0),
_y(0),
_enabled(true),
_action(NULL)
{
}
EAHitBox::~EAHitBox()
{
}
bool EAHitBox::checkContains(short x, short y)
{
bool result = false;
if (
(x > this->x())
&&
(x < this->x() + width())
&&
(y > this->y())
&&
(y < this->y() + height())
)
{
// This is a hit.
result = true;
}
if ((result == true) && (enabled() == true))
{
// Hit inside and an action is defined.
if (_handler != NULL)
{
// Call member function on object.
_handler->actionHandler(this, x, y);
}
if (_action != NULL)
{
// Call global handler.
_action(this, x, y);
}
}
return result;
}