armory/Sources/armory/logicnode/MouseCoordsNode.hx

30 lines
510 B
Haxe
Raw Permalink Normal View History

2017-04-03 22:29:46 +02:00
package armory.logicnode;
2017-11-20 15:16:52 +01:00
import iron.math.Vec4;
2017-04-03 22:29:46 +02:00
2017-04-10 21:17:17 +02:00
class MouseCoordsNode extends LogicNode {
2017-04-03 22:29:46 +02:00
var coords = new Vec4();
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-04 23:11:31 +02:00
super(tree);
2017-04-03 22:29:46 +02:00
}
2019-12-19 23:54:08 +01:00
override function get(from: Int): Dynamic {
2017-11-20 15:16:52 +01:00
var mouse = iron.system.Input.getMouse();
2017-04-03 22:29:46 +02:00
if (from == 0) {
2017-04-10 21:17:17 +02:00
coords.x = mouse.x;
coords.y = mouse.y;
2017-04-08 00:34:45 +02:00
return coords;
2017-04-03 22:29:46 +02:00
}
else if (from == 1) {
2017-04-10 21:17:17 +02:00
coords.x = mouse.movementX;
coords.y = mouse.movementY;
2017-04-08 00:34:45 +02:00
return coords;
}
else {
2017-04-10 21:17:17 +02:00
return mouse.wheelDelta;
2017-04-03 22:29:46 +02:00
}
}
}