blob: 9d75a7521cd6de5c08d0197c8ec001869cc17c46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "MoveCameraManualyScript.h"
using namespace crepe;
using namespace std;
void MoveCameraManualyScript::init() {
subscribe<KeyPressEvent>([this](const KeyPressEvent & ev) -> bool {
return this->keypressed(ev);
});
}
bool MoveCameraManualyScript::keypressed(const KeyPressEvent & event) {
if (event.key == Keycode::RIGHT) {
Transform & cam = this->get_components_by_name<Transform>("camera").front();
cam.position.x += 100;
return true;
} else if (event.key == Keycode::LEFT) {
Transform & cam = this->get_components_by_name<Transform>("camera").front();
cam.position.x -= 100;
return true;
}
return false;
}
|