diff --git a/TextButtonInstance.cpp b/TextButtonInstance.cpp index 916fe73..523c918 100644 --- a/TextButtonInstance.cpp +++ b/TextButtonInstance.cpp @@ -42,6 +42,31 @@ TextButtonInstance::TextButtonInstance(void) disabled = false; } +bool TextButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd) +{ + Vector3 point1; + Vector3 point2; + if(floatBottom) + { + point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0); + point2 = Vector3(boxEnd.x, rd->getHeight() + boxEnd.y,0); + + } + else + { + point1 = Vector3(boxBegin.x, boxBegin.y,0); + point2 = Vector3(boxEnd.x, boxEnd.y,0); + } + if(mousex >= point1.x && mousey >= point1.y) + { + if(mousex < point2.x && mousey < point2.y) + { + return true; + } + } + return false; +} + void TextButtonInstance::setAllColorsSame() { textColorOvr = textColor; diff --git a/TextButtonInstance.h b/TextButtonInstance.h index fe1c4e2..2f8823c 100644 --- a/TextButtonInstance.h +++ b/TextButtonInstance.h @@ -27,4 +27,5 @@ public: bool visible; int textSize; void drawObj(RenderDevice*, Vector2, bool); + bool mouseInButton(float, float, RenderDevice*); }; \ No newline at end of file