Files
Leenkx_Examples/game_endlessrun/Sources/lnx/PlayerController.hx
2026-05-06 17:52:45 -07:00

23 lines
499 B
Haxe

package lnx;
class PlayerController extends iron.Trait {
public function new() {
super();
notifyOnUpdate(function() {
var kb = iron.system.Input.getKeyboard();
var x = object.transform.loc.x;
// Move player
if ((kb.down("left") || kb.down("a")) && x > -1.8) {
object.transform.loc.x -= 0.06;
object.transform.dirty = true;
}
if ((kb.down("right") || kb.down("d")) && x < 1.8) {
object.transform.loc.x += 0.06;
object.transform.dirty = true;
}
});
}
}