helm-0.5.0: A functionally reactive game engine.

Safe HaskellNone

FRP.Helm.Animation

Contents

Description

Contains all data structures and functions for creating and stepping animations.

Synopsis

Types

type Frame = (Time, Form)Source

A type describing a single frame in an animation. A frame consists of a time at which the frame takes place in an animation and the form which is how the frame actually looks when rendered.

type Animation = [Frame]Source

A type describing an animation consisting of a list of frames.

data Status Source

This type tells of the state an animation is in. Continue: A continued animation plays through its frames as specified in the Animation. Pause: A paused animation does not change its current frame and time. Stop: A stopped animation is set to its first frame and time 0. Frame: The Frame constructor can be used to choose a specific frame of the animation where time is set to the first millisecond of that chosen frame. (Indexing starts at 1. 'first frame', not 'zero frame') Time: The Time constructor sets the current time (in milliseconds) in the animation to the specified value.

Constructors

Continue 
Pause 
Stop 
Frame Int 
Time Time 

Creating

absolute :: [Frame] -> AnimationSource

Creates an animation from a list of frames. The time value in each frame is absolute to the entire animation, i.e. each time value is the time at which the frame takes place relative to the starting time of the animation.

relative :: [Frame] -> AnimationSource

Creates an animation from a list of frames. The time value in each frame is relative to other frames, i.e. each time value is the difference in time from the last frame.

 relative [(100, picture1), (100, picture2), (300, picture3)] == absolute [(100, picture1), (200, picture2), (500, picture3)]

Animating

animate :: Animation -> SignalGen (Signal Time) -> SignalGen (Signal Status) -> SignalGen (Signal Form)Source

Creates a signal contained in a generator that returns the current form in the animation when sampled from a specific animation. The second argument is a signal generator containing a signal that returns the time to setup the animation forward when sampled. The third argument is a signal generator containing a signal that returns true to continue animating or false to stop animating when sampled.

formAt :: Animation -> Time -> Maybe FormSource

The form that will be rendered for a specific time in an animation.

length :: Animation -> TimeSource

The amount of time one cycle of the animation takes.