I have an event SF Input (Event ())
that represents the key-up of the space key. I have some gravity
and every time the user releases the key, it must switch between 1
and (-1)
. So I did this:
gravity <- accumHold 1 <<< (arr $ tag (*(-1))) <<< keyUp SDLK_SPACE -< ev
But what it does is switching the value up and down on repeate until I press the key again. I have no idea where I did wrong there.
The full source is found here, maybe someone can help me.
The obvious answer is to use a switch:
This is certainly also possible without a switch by mapping over the event values, but the switch seems to be the natural solution. You can also use Netwire, which makes this a lot simpler:
The
iterateW
wire will be available in Netwire 4. Until then you can write it this way: