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> <PropertyList>
<nasal> <nasal>
<script> <script>
contains(caller(0)[0], "stick") and removelistener(stick.listener);
var stick = { var stick = {
init: func { init: func {
me.x = me.y = 0; 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.angle = n.getValue() * D2R;
me.sin = math.sin(me.angle); me.sin = math.sin(me.angle);
me.cos = math.cos(me.angle); me.cos = math.cos(me.angle);
@ -32,6 +35,7 @@
setprop("/controls/flight/elevator", me.y * me.cos - me.x * me.sin); setprop("/controls/flight/elevator", me.y * me.cos - me.x * me.sin);
}, },
}; };
stick.init(); stick.init();
</script> </script>
</nasal> </nasal>