warthog: stick_rotate: re-attach listeners (nicer for development)
This commit is contained in:
parent
487372e6b0
commit
a29f5d63e2
1 changed files with 5 additions and 1 deletions
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue