-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonScript.cpp
More file actions
34 lines (26 loc) · 1006 Bytes
/
Copy pathButtonScript.cpp
File metadata and controls
34 lines (26 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "ButtonScript.h"
void ButtonScript::tickScript(float deltaTime) {
ComponentHandle<Transform> transform = entity->get<Transform>();
ComponentHandle<BoxCollider> collider = entity->get<BoxCollider>();
ComponentHandle<Sprite> sprite = entity->get<Sprite>();
if (!clicked) {
if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS) {
double mouseX, mouseY;
glfwGetCursorPos(window, &mouseX, &mouseY);
if (mouseX >= transform->position.x - collider->width / 2.0f && mouseX <= transform->position.x + collider->width / 2.0f &&
mouseY >= transform->position.y - collider->height / 2.0f && mouseY <= transform->position.y + collider->height / 2.0f) {
//cout << "Button Clicked " << endl;
clicked = true;
sprite->visible = false;
welcRef->turnVisible(false);
gameRef->startGame();
}
}
}
}
void ButtonScript::setTextScriptRef(TextScript* welcs) {
welcRef = welcs;
}
void ButtonScript::setGameManagerRef(GameManager* gmr) {
gameRef = gmr;
}