Safe Haskell | None |
---|
Contains functions for composing units of time and signals that sample from the game clock.
- type Time = Double
- millisecond :: Time
- second :: Time
- minute :: Time
- hour :: Time
- inMilliseconds :: Time -> Double
- inSeconds :: Time -> Double
- inMinutes :: Time -> Double
- inHours :: Time -> Double
- fps :: Double -> Signal Time
- fpsWhen :: Double -> Signal Bool -> Signal Time
- every :: Time -> Signal Time
- timestamp :: Signal a -> Signal (Time, a)
- delay :: Time -> Signal a -> Signal a
- since :: Time -> Signal a -> Signal Bool
Units
A type describing an amount of time in an arbitary unit. Use the time composing/converting functions to manipulate time values.
A time value representing one millisecond.
inMilliseconds :: Time -> DoubleSource
Converts a time value to a fractional value, in milliseconds.
Tickers
fps :: Double -> Signal TimeSource
Takes desired number of frames per second (fps). The resulting signal gives a sequence of time deltas as quickly as possible until it reaches the desired FPS. A time delta is the time between the last frame and the current frame.
fpsWhen :: Double -> Signal Bool -> Signal TimeSource
Same as the fps function, but you can turn it on and off. Allows you to do brief animations based on user input without major inefficiencies. The first time delta after a pause is always zero, no matter how long the pause was. This way summing the deltas will actually give the amount of time that the output signal has been running.
every :: Time -> Signal TimeSource
Takes a time interval t. The resulting signal is the current time, updated every t.
Timing
timestamp :: Signal a -> Signal (Time, a)Source
Add a timestamp to any signal. Timestamps increase monotonically. When you create (timestamp Mouse.x), an initial timestamp is produced. The timestamp updates whenever Mouse.x updates.
Unlike in Elm the timestamps are not tied to the underlying signals so the timestamps for Mouse.x and Mouse.y will be slightly different.