From 4912eb6946734a540a81cef97bcf0d418b73406f Mon Sep 17 00:00:00 2001 From: jonas Date: Thu, 3 Jan 2019 21:19:20 +0100 Subject: a --- cObjectHandler.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cObjectHandler.cpp') diff --git a/cObjectHandler.cpp b/cObjectHandler.cpp index 68abace..0b4bb65 100644 --- a/cObjectHandler.cpp +++ b/cObjectHandler.cpp @@ -77,11 +77,13 @@ int cObjectHandler::clickEvent(sPos _pos, unsigned int _button) return 1; if(_pos.y >= iHitMap[_pos.x].size()) return 1; - - iActiveObject = iHitMap[_pos.x][_pos.y]; //Set active object + if(objects[ iHitMap[_pos.x][_pos.y] ]) + { + iActiveObject = iHitMap[_pos.x][_pos.y]; //Set active object objects[ iHitMap[_pos.x][_pos.y] ]->onClick(_pos, _button); + } else return 1; @@ -139,9 +141,9 @@ void cObjectHandler::buildHitmap() sPos oPos = objects[i]->getPosition(); sPos oSize = objects[i]->getSize(); - for(unsigned int x = oPos.x; x <= oPos.x + oSize.x; x++) + for(int x = oPos.x; x <= oPos.x + oSize.x; x++) { - for(unsigned int y = oPos.y; y <= oPos.y + oSize.y; y++) + for(int y = oPos.y; y <= oPos.y + oSize.y; y++) { if(x < size.x && y < size.y) //Objects can be outside the screen. iHitMap[x][y] = i; -- cgit v1.2.3