1
0
Fork 0

warthog: stick_rotate: re-attach listeners (nicer for development)

This commit is contained in:
Melchior FRANZ 2011-12-10 20:13:05 +01:00
parent 487372e6b0
commit a29f5d63e2

View file

@ -9,10 +9,13 @@
<PropertyList>
<nasal>
<script>
contains(caller(0)[0], "stick") and removelistener(stick.listener);
var stick = {
init: func {
me.x = me.y = 0;
jslistener("/input/joysticks/stick-angle", func(n) {
var a = props.globals.initNode("/input/joysticks/stick-angle");
me.listener = setlistener(a, func(n) {
me.angle = n.getValue() * D2R;
me.sin = math.sin(me.angle);
me.cos = math.cos(me.angle);
@ -32,6 +35,7 @@
setprop("/controls/flight/elevator", me.y * me.cos - me.x * me.sin);
},
};
stick.init();
</script>
</nasal>