MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / onKeyPressed

Method onKeyPressed

Source/LevelEditorLayer.cpp:161–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159};
160
161void LevelEditorLayer::onKeyPressed(ax::EventKeyboard::KeyCode keyCode, ax::Event* event)
162{
163 float speed = 7.f;
164
165 float new_pos = 30.f;
166 bool new_posX = false;
167 bool new_posY = false;
168
169 if (_shiftPressed) {
170 new_pos = 2.f;
171 }
172
173 float scaling = 1.f;
174
175 if (_shiftPressed) {
176 scaling = 0.1f;
177 }
178
179 switch (keyCode)
180 {
181 case ax::EventKeyboard::KeyCode::KEY_A: {
182 m_camDelta.x = -speed;
183 }
184 break;
185 case ax::EventKeyboard::KeyCode::KEY_D: {
186 m_camDelta.x = speed;
187 }
188 break;
189 case ax::EventKeyboard::KeyCode::KEY_W: {
190 m_camDelta.y = speed;
191 }
192 break;
193 case ax::EventKeyboard::KeyCode::KEY_S: {
194 m_camDelta.y = -speed;
195 }
196 break;
197 case ax::EventKeyboard::KeyCode::KEY_R: {
198 if (_selectedObjectReal != nullptr) {
199 _selectedObjectReal->setRotation(_selectedObjectReal->getRotation() + 90.f);
200 }
201 }
202 break;
203 case ax::EventKeyboard::KeyCode::KEY_ESCAPE: {
204 exit();
205 }
206 break;
207 case ax::EventKeyboard::KeyCode::KEY_SHIFT: {
208 _shiftPressed = true;
209 }
210 break;
211 case ax::EventKeyboard::KeyCode::KEY_LEFT_ARROW: {
212 if (_selectedObjectReal) {
213 auto pos = _selectedObjectReal->getPosition();
214 new_pos = -new_pos;
215 pos.x += new_pos;
216 _selectedObjectReal->setPosition(pos);
217 _selectedObjectReal->setStartPositionX(pos.x);
218 new_posX = true;

Callers

nothing calls this directly

Calls 6

setRotationMethod · 0.80
setPositionMethod · 0.80
setStartPositionXMethod · 0.80
setStartPositionYMethod · 0.80
getStartScaleMethod · 0.80
setStartScaleMethod · 0.80

Tested by

no test coverage detected