예제 #1
0
DrawableObject* ApplicationState::getObjectClicked(Vector2d& mousePosition, int layer)
{
  DrawableObject * closestObject = clickableObjects[layer].findClosest(mousePosition);

  if (closestObject != NULL && closestObject->isClicked(mousePosition))
    return closestObject;
  return NULL;
}
예제 #2
0
DrawableObject* ApplicationState::getObjectClicked()
{
  DrawableObject *  closestObject = NULL;
  DrawableObject *  clickedObject = NULL;
  int highestLayer = 0;
  for (auto it = clickableObjects.begin(); it != clickableObjects.end(); it++)
  {
    closestObject = it->second.findClosest(mousePosition);

    if (closestObject != NULL && closestObject->isClicked(mousePosition))
    {
      // remember the QuadTrees are indexed on their layers
      if (it->first > highestLayer)
      {
        clickedObject = closestObject;
        highestLayer = it->first;
      }
    }
  }
  return clickedObject;
}