blob: 0181333ea76fd479a2d685cef54849a996e6df25 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#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;
}
|