helm-0.6.2: 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 AnimationStatus Source

A data structure that can be used to manage the status of the animation.

Constructors

Cycle

The animation continues to play through its frames.

Pause

The animation is paused.

Stop

The animation is stopped, jumping back to the first frame and initial time.

SetFrame Int

The animation is set to a specific one-indexed frame.

SetTime Time

The animation is set to a specific time and its related frame.

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 * millisecond, picture1), (100 * millisecond, picture2)] == absolute [(100 * millisecond, picture1), (200 * millisecond, picture2)]

Animating

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

Creates a signal that returns the current form in the animation when sampled from a specific animation. The second argument is a signal that returns the time to setup the animation forward when sampled. The third argument is a signal that returns the status of the animation, allowing you to control it.

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.