Copyright | [2014] Manuel M T Chakravarty |
---|---|
License | BSD3 |
Maintainer | Manuel M T Chakravarty <chak@justtesting.org> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
- Basic geometry and similar
- Marshalling functions (internal)
- Color representation
- Colour representation
- Colours in the sRGBA colour space
- Standard colours
- Marshalling support (internal)
- Bit images and textures
- Vector paths
- Core Graphics path representation
- Marshalling functions (internal)
- Nodes and scenes
- Scene representation
- Scene creation
- Marshalling functions (internal)
- Actions animating nodes
- SpriteKit actions
- Marshalling support (internal)
- User events
- Event information
- Marshalling functions (internal)
- Internal
Cocoa SpriteKit for Haskell
Concepts:
- SpriteKit node trees are represented as conventional algebraic datatypes in Haskell.
- For rendering, Haskell node trees are converted to native
SKNode
trees. For animated scenes, where all animation is driven by Haskell, the conversion of updated scenes works by updating the previousSKNode
tree. - For interactive scenes and scenes using SceneKit's actions or physics, the Haskell scene code gets called with a Haskell
tree representing the current
SKNode
tree, which, after Haskell side processing, is converted to anSKNode
tree again by updating the version that was passed to the Haskell code.
- type TimeInterval = Double
- type GFloat = Double
- data Point = Point {}
- data Size = Size {
- sizeWidth :: !GFloat
- sizeHeight :: !GFloat
- data Rect = Rect {
- rectOrigin :: !Point
- rectSize :: !Size
- data Vector = Vector {}
- pointZero :: Point
- sizeZero :: Size
- rectZero :: Rect
- vectorZero :: Vector
- pointToCGPoint :: Point -> IO CGPoint
- cgPointToPoint :: CGPoint -> IO Point
- sizeToCGSize :: Size -> IO CGSize
- cgSizeToSize :: CGSize -> IO Size
- rectToCGRect :: Rect -> IO CGRect
- cgRectToRect :: CGRect -> IO Rect
- vectorToCGVector :: Vector -> IO CGVector
- cgVectorToVector :: CGVector -> IO Vector
- geometry_initialise :: IO ()
- newtype Color = Color SKColor
- colorWithRGBA :: Float -> Float -> Float -> Float -> Color
- rgbaOfColor :: Color -> (Float, Float, Float, Float)
- blackColor :: Color
- blueColor :: Color
- clearColor :: Color
- cyanColor :: Color
- darkGrayColor :: Color
- grayColor :: Color
- greenColor :: Color
- lightGrayColor :: Color
- magentaColor :: Color
- orangeColor :: Color
- purpleColor :: Color
- redColor :: Color
- whiteColor :: Color
- yellowColor :: Color
- newtype SKColor = SKColor (ForeignPtr SKColor)
- colorToSKColor :: Color -> SKColor
- colorToForeignPtr :: Color -> IO (ForeignPtr SKColor)
- color_initialise :: IO ()
- data Image
- class IsImage img where
- newtype NSUIImage = NSUIImage (ForeignPtr NSUIImage)
- imageToNSUIImage :: IsImage img => img -> IO NSUIImage
- imageToForeignPtr :: IsImage img => img -> IO (ForeignPtr NSUIImage)
- image_initialise :: IO ()
- newtype Texture = Texture SKTexture
- textureWithImageNamed :: FilePath -> Texture
- textureWithImage :: Image -> Texture
- textureWithRectInTexture :: Rect -> Texture -> Texture
- textureSize :: Texture -> Size
- textureRect :: Texture -> Rect
- newtype SKTexture = SKTexture (ForeignPtr SKTexture)
- textureToSKTexture :: Texture -> SKTexture
- textureToForeignPtr :: Texture -> IO (ForeignPtr SKTexture)
- texture_initialise :: IO ()
- type Path = [PathElement]
- data PathElement
- newtype CGPath = CGPath (ForeignPtr CGPath)
- pathToCGPath :: Path -> IO CGPath
- cgPathToPath :: CGPath -> IO Path
- path_initialise :: IO ()
- data Directive node
- = RunAction (Action node) (Maybe String)
- | RemoveActionForKey String
- | RemoveAllActions
- data Node u
- = Node {
- nodeName :: Maybe String
- nodePosition :: Point
- nodeZPosition :: GFloat
- nodeXScale :: GFloat
- nodeYScale :: GFloat
- nodeZRotation :: GFloat
- nodeChildren :: [Node u]
- nodeActionDirectives :: [Directive (Node u)]
- nodeSpeed :: GFloat
- nodePaused :: Bool
- nodeUserData :: u
- nodeForeign :: Maybe SKNode
- | Label {
- nodeName :: Maybe String
- nodePosition :: Point
- nodeZPosition :: GFloat
- nodeXScale :: GFloat
- nodeYScale :: GFloat
- nodeZRotation :: GFloat
- nodeChildren :: [Node u]
- nodeActionDirectives :: [Directive (Node u)]
- nodeSpeed :: GFloat
- nodePaused :: Bool
- nodeUserData :: u
- nodeForeign :: Maybe SKNode
- labelText :: String
- labelFontColor :: Color
- labelFontName :: Maybe String
- labelFontSize :: GFloat
- | Shape {
- nodeName :: Maybe String
- nodePosition :: Point
- nodeZPosition :: GFloat
- nodeXScale :: GFloat
- nodeYScale :: GFloat
- nodeZRotation :: GFloat
- nodeChildren :: [Node u]
- nodeActionDirectives :: [Directive (Node u)]
- nodeSpeed :: GFloat
- nodePaused :: Bool
- nodeUserData :: u
- nodeForeign :: Maybe SKNode
- shapePath :: Path
- shapeFillColor :: Color
- shapeLineWidth :: GFloat
- shapeGlowWidth :: GFloat
- shapeAntialiased :: Bool
- shapeStrokeColor :: Color
- | Sprite {
- nodeName :: Maybe String
- nodePosition :: Point
- nodeZPosition :: GFloat
- nodeXScale :: GFloat
- nodeYScale :: GFloat
- nodeZRotation :: GFloat
- nodeChildren :: [Node u]
- nodeActionDirectives :: [Directive (Node u)]
- nodeSpeed :: GFloat
- nodePaused :: Bool
- nodeUserData :: u
- nodeForeign :: Maybe SKNode
- spriteSize :: Size
- spriteAnchorPoint :: Point
- spriteTexture :: Maybe Texture
- spriteColorBlendFactor :: GFloat
- spriteColor :: Color
- = Node {
- type TimedUpdate node = node -> GFloat -> node
- runAction :: Action userData -> Directive userData
- runActionWithKey :: Action userData -> String -> Directive userData
- removeActionForKey :: String -> Directive userData
- removeAllActions :: Directive userData
- node :: [Node userData] -> Node userData
- labelNodeWithFontNamed :: String -> Node userData
- labelNodeWithText :: String -> Node userData
- shapeNodeWithPath :: Path -> Node userData
- spriteWithColorSize :: Color -> Size -> Node userData
- spriteWithImageNamed :: FilePath -> Node userData
- spriteWithTexture :: Texture -> Node userData
- spriteWithTextureSize :: Texture -> Size -> Node userData
- spriteWithTextureColorSize :: Texture -> Color -> Size -> Node userData
- newtype SKNode = SKNode (ForeignPtr SKNode)
- nodeToSKNode :: Node userData -> IO SKNode
- addChildren :: Bool -> SKNode -> [Node userData] -> IO ()
- addActionDirectives :: SKNode -> [Directive userData] -> IO ()
- unsafeInterleaveNSArrayTolistOfNode :: NSArray SKNode -> IO [Node userData]
- updateChildren :: SKNode -> [Node userData] -> [Node userData] -> IO ()
- nodeToForeignPtr :: Node userData -> IO (ForeignPtr SKNode)
- node_initialise :: IO ()
- data Scene sceneData nodeData = Scene {
- sceneName :: Maybe String
- sceneChildren :: [Node nodeData]
- sceneActionDirectives :: [Directive (Scene sceneData nodeData)]
- sceneSpeed :: GFloat
- sceneData :: sceneData
- scenePaused :: Bool
- sceneAnchorPoint :: Point
- sceneSize :: Size
- sceneScaleMode :: SceneScaleMode
- sceneBackgroundColor :: Color
- sceneUpdate :: Maybe (SceneUpdate sceneData nodeData)
- sceneHandleEvent :: Maybe (EventHandler sceneData)
- type EventHandler userData = Event -> userData -> Maybe userData
- sceneWithSize :: Size -> Scene sceneData nodeData
- sceneToSKNode :: Scene sceneData nodeData -> IO SKNode
- sceneToForeignPtr :: Scene sceneData nodeData -> IO (ForeignPtr SKNode)
- scene_initialise :: IO ()
- data ActionSpecification node
- = MoveBy !Vector
- | MoveTo !Point
- | MoveToX !GFloat
- | MoveToY !GFloat
- | FollowPath Path !Bool !Bool
- | FollowPathSpeed Path !Bool !Bool !GFloat
- | RotateByAngle !GFloat
- | RotateToAngle !GFloat
- | RotateToAngleShortestUnitArc !GFloat !Bool
- | SpeedBy !GFloat
- | SpeedTo !GFloat
- | ScaleBy !GFloat !GFloat
- | ScaleTo !GFloat !GFloat
- | ScaleXTo !GFloat
- | ScaleYTo !GFloat
- | Unhide
- | Hide
- | FadeIn
- | FadeOut
- | FadeAlphaBy !GFloat
- | FadeAlphaTo !GFloat
- | ResizeByWidthHeight !GFloat !GFloat
- | ResizeToHeight !GFloat
- | ResizeToWidth !GFloat
- | ResizeToWidthHeight !GFloat !GFloat
- | SetTexture Texture !Bool
- | AnimateWithTextures [Texture] !TimeInterval !Bool !Bool
- | ColorizeWithColor Color !GFloat
- | ColorizeWithColorBlendFactor !GFloat
- | PlaySoundFileNamed String !Bool
- | RemoveFromParent
- | RunActionOnChildWithName (Action node) String
- | Group [Action node]
- | Sequence [Action node]
- | RepeatActionCount (Action node) !Int
- | RepeatActionForever (Action node)
- | WaitForDuration !TimeInterval
- | CustomAction (TimedUpdate node)
- data Action node = Action {}
- data ActionTimingMode
- type ActionTimingFunction = Float -> Float
- action :: ActionSpecification node -> Action node
- moveBy :: Vector -> Action node
- moveTo :: Point -> Action node
- moveToX :: GFloat -> Action node
- moveToY :: GFloat -> Action node
- followPath :: Path -> Action node
- followPathSpeed :: Path -> GFloat -> Action node
- followPathAsOffsetOrientToPath :: Path -> Bool -> Bool -> Action node
- followPathAsOffsetOrientToPathSpeed :: Path -> Bool -> Bool -> GFloat -> Action node
- rotateByAngle :: GFloat -> Action node
- rotateToAngle :: GFloat -> Action node
- rotateToAngleShortestUnitArc :: GFloat -> Bool -> Action node
- speedBy :: GFloat -> Action node
- speedTo :: GFloat -> Action node
- scaleBy :: GFloat -> Action node
- scaleTo :: GFloat -> Action node
- scaleXByY :: GFloat -> GFloat -> Action node
- scaleXToX :: GFloat -> GFloat -> Action node
- scaleXTo :: GFloat -> Action node
- scaleYTo :: GFloat -> Action node
- hide :: Action node
- unhide :: Action node
- fadeIn :: Action node
- fadeOut :: Action node
- fadeAlphaBy :: GFloat -> Action node
- fadeAlphaTo :: GFloat -> Action node
- resizeByWidthHeight :: GFloat -> GFloat -> Action node
- resizeToHeight :: GFloat -> Action node
- resizeToWidth :: GFloat -> Action node
- resizeToWidthHeight :: GFloat -> GFloat -> Action node
- setTexture :: Texture -> Action node
- setTextureResize :: Texture -> Bool -> Action node
- animateWithTexturesTimePerFrame :: [Texture] -> TimeInterval -> Action node
- animateWithTextures :: [Texture] -> TimeInterval -> Action node
- animateWithTexturesTimePerFrameResizeRestore :: [Texture] -> TimeInterval -> Bool -> Bool -> Action node
- animateWithTexturesResizeRestore :: [Texture] -> TimeInterval -> Bool -> Bool -> Action node
- colorizeWithColorColorBlendFactor :: Color -> GFloat -> Action node
- colorizeWithColor :: Color -> GFloat -> Action node
- colorizeWithColorBlendFactor :: GFloat -> Action node
- playSoundFileNamedWaitForCompletion :: String -> Bool -> Action node
- playSoundFileNamed :: String -> Bool -> Action node
- removeFromParent :: Action node
- runActionOnChildWithName :: Action node -> String -> Action node
- group :: [Action node] -> Action node
- groupActions :: [Action node] -> Action node
- sequence :: [Action node] -> Action node
- sequenceActions :: [Action node] -> Action node
- repeatActionCount :: Action node -> Int -> Action node
- repeatActionForever :: Action node -> Action node
- waitForDuration :: Action node
- waitForDurationWithRange :: TimeInterval -> Action node
- customAction :: TimedUpdate node -> Action node
- newtype SKAction = SKAction (ForeignPtr SKAction)
- actionToSKAction :: Action node -> IO SKAction
- data TimedUpdateBox node = TimedUpdateBox (TimedUpdate node)
- action_initialise :: IO ()
- data Event
- = KeyEvent { }
- | MouseEvent { }
- | EnterExitEvent { }
- | OtherEvent { }
- data KeyEvent
- = KeyDown
- | KeyUp
- | FlagsChanged
- data MouseEvent
- data EnterExitEvent = CursorUpdate
- data OtherEvent = Periodic
- keyEvent :: Point -> Double -> CLong -> String -> String -> Bool -> Word16 -> Event
- mouseEvent :: Point -> Double -> CLong -> Int -> Int -> Int -> Float -> Event
- event_initialise :: IO ()
- spritekit_initialise :: IO ()
Basic geometry and similar
Basic temporal definition
type TimeInterval = Double
Basic geometry definitions
type GFloat
= Double | FIXME: need to be set in dependence on the definition of |
data Point
Point in a two-dimensional coordinate system.
data Vector
Two-dimensional vector.
vectorZero :: Vector
Marshalling functions (internal)
pointToCGPoint :: Point -> IO CGPoint
cgPointToPoint :: CGPoint -> IO Point
sizeToCGSize :: Size -> IO CGSize
cgSizeToSize :: CGSize -> IO Size
rectToCGRect :: Rect -> IO CGRect
cgRectToRect :: CGRect -> IO Rect
vectorToCGVector :: Vector -> IO CGVector
cgVectorToVector :: CGVector -> IO Vector
geometry_initialise :: IO ()
Color representation
Colour representation
Colours in the sRGBA colour space
colorWithRGBA :: Float -> Float -> Float -> Float -> Color
Create colour with the specified red, green, blue, and alpha channel values in the sRGB colour space.
rgbaOfColor :: Color -> (Float, Float, Float, Float)
Extract the red, green, blue, and alpha channel values of a colour in the sRGB colour space.
Standard colours
blackColor :: Color
clearColor :: Color
greenColor :: Color
orangeColor :: Color
purpleColor :: Color
whiteColor :: Color
yellowColor :: Color
Marshalling support (internal)
newtype SKColor
colorToSKColor :: Color -> SKColor
colorToForeignPtr :: Color -> IO (ForeignPtr SKColor)
color_initialise :: IO ()
Bit images and textures
Images
class IsImage img where
Marshalling functions (internal)
newtype NSUIImage
imageToNSUIImage :: IsImage img => img -> IO NSUIImage
imageToForeignPtr :: IsImage img => img -> IO (ForeignPtr NSUIImage)
image_initialise :: IO ()
SpriteKit texture representation
Texture creation
textureWithImageNamed :: FilePath -> Texture
Create a texture from an image in the app bundle (either a file or an image in a texture atlas) or external file.
A placeholder image is used if the specified image cannot be loaded.
In case of a relative name, the look up behaviour varies between a compiled application bundle and running in the interpreter. In case of a compiled application bundle, the standard SpriteKit bundle behaviour applies. In case of executing in the interpreter, we first look for assets relative to the current working directory.
textureWithImage :: Image -> Texture
Create a texture from the given image.
textureWithRectInTexture :: Rect -> Texture -> Texture
Create a texture from a subset of an existing texture.
The original and new texture share the same texture data. In further call to the same function, the rectangle is again specified in terms of the *original* texture.
Texture properties
textureSize :: Texture -> Size
The size of the texture.
textureRect :: Texture -> Rect
The rectangle (in the unit coordinate space) that defines the portion of the texture used to render its image.
The default is (0,0) — (1,1), but it may be different for textures created with textureWithRectInTexture
.
Marshalling support
newtype SKTexture
textureToForeignPtr :: Texture -> IO (ForeignPtr SKTexture)
texture_initialise :: IO ()
Vector paths
Core Graphics path representation
type Path = [PathElement]
Description of a graphics path.
data PathElement
Elementary components of a graphics path.
The constructors AddLineToPoint
, AddQuadCurveToPoint
, AddCurveToPoint
may not start a graphics path.
MoveToPoint !Point | Starts a new subpath at the given point. |
AddLineToPoint !Point | Adds a line from the current to the given point. |
AddQuadCurveToPoint !Point !Point | Adds a quadratic curve with control and destination point. |
AddCurveToPoint !Point !Point !Point | Adds a cubic curve with two control and one destination point. |
CloseSubpath | Closes and completes the current subpath. FIXME: we might to add field names (esp useful for the quadratic and cubic curves) |
Marshalling functions (internal)
newtype CGPath
pathToCGPath :: Path -> IO CGPath
cgPathToPath :: CGPath -> IO Path
path_initialise :: IO ()
Nodes and scenes
SpriteKit node representation
data Directive node
Specification of changes that should be made to a node's actions.
RunAction (Action node) (Maybe String) | Initiate a new action, possibly named. |
RemoveActionForKey String | Remove a named action. |
RemoveAllActions | Remove all current actions. |
data Node u
Tree structure of SpriteKit nodes that are used to assemble scenes, parameterised by the type of user data u
.
FIXME: or should we factorise into a two-level structure? (but that would make it awkward to use record updates)
Node | |
| |
Label | |
| |
Shape | |
| |
Sprite | |
|
type TimedUpdate node = node -> GFloat -> node
Function that computes an updated tree, given the time that elapsed since the start of the current animation.
The result will be ignored if the new node is not derived from the old node — i.e, it must be the same kind of node
and it must preserve the nodeForeign
field.
Action directives
runActionWithKey :: Action userData -> String -> Directive userData
Initiate a new action and give it a name.
If an action with the same name is currently underway on a node that receives this action, the old action is removed first.
removeActionForKey :: String -> Directive userData
Instructs to remove any action with the give name.
removeAllActions :: Directive userData
Instructs to remove all actions from any node that receives this directive.
Generic SpriteKit node functionality
node :: [Node userData] -> Node userData
Create a node that combines multiple child nodes, but doesn't have a visual representation of its own.
Label nodes
labelNodeWithFontNamed :: String -> Node userData
Creates a label node without any text, but using the specified font.
labelNodeWithText :: String -> Node userData
Creates a label node with the given text (set in 32pt Helvetica Neue Ultralight).
Shape nodes
shapeNodeWithPath :: Path -> Node userData
Creates a shape node from a graphics path relative to the nodes origin.
Sprite nodes
spriteWithColorSize :: Color -> Size -> Node userData
Create a coloured sprite of a given size.
spriteWithImageNamed :: FilePath -> Node userData
Create a texture sprite from an image in the app bundle (either a file or an image in a texture atlas).
A placeholder image is used if the image cannot be loaded.
spriteWithTexture :: Texture -> Node userData
Create a textured sprite from an in-memory texture.
spriteWithTextureSize :: Texture -> Size -> Node userData
Create a textured sprite from an in-memory texture, but also set an explicit size (instead of using the texture's size).
spriteWithTextureColorSize :: Texture -> Color -> Size -> Node userData
Create a textured sprite from an in-memory texture, but also set an explicit size (instead of using the texture's size).
NB: To colourise the texture, you also need to set the colorBlendFactor
field of the sprite.
Internal marshalling support
newtype SKNode
nodeToSKNode :: Node userData -> IO SKNode
addChildren :: Bool -> SKNode -> [Node userData] -> IO ()
addActionDirectives :: SKNode -> [Directive userData] -> IO ()
unsafeInterleaveNSArrayTolistOfNode :: NSArray SKNode -> IO [Node userData]
updateChildren :: SKNode -> [Node userData] -> [Node userData] -> IO ()
nodeToForeignPtr :: Node userData -> IO (ForeignPtr SKNode)
node_initialise :: IO ()
Scene representation
data Scene sceneData nodeData
SpriteKit scene description.
Scene | |
|
type EventHandler userData = Event -> userData -> Maybe userData
Event handler that given an input event and node data decides whether to handle the event and how to update the node data.
If the handler chooses not to handle the presented event, it returns Nothing
. In this case, the event will be forwarded to
the next item in the responder chain.
Scene creation
sceneWithSize :: Size -> Scene sceneData nodeData
A new scene of the given size.
Marshalling functions (internal)
sceneToSKNode :: Scene sceneData nodeData -> IO SKNode
sceneToForeignPtr :: Scene sceneData nodeData -> IO (ForeignPtr SKNode)
scene_initialise :: IO ()
Actions animating nodes
SpriteKit actions
data ActionSpecification node
Specification of an action that can be applied to a SpriteKit node.
Most actions will be animated over time, given a duration.
MoveBy !Vector | Move relative to current position (reversible). |
MoveTo !Point | Move to an absolute position (irreversible). |
MoveToX !GFloat | Move horizontally to an absolute x-position (irreversible). |
MoveToY !GFloat | Move vertically to an absolute y-position (irreversible). |
FollowPath Path !Bool !Bool | Follow path, maybe use relative offsets & maybe orient according to path (reversible). |
FollowPathSpeed Path !Bool !Bool !GFloat | As above, but specifying speed in points per sec (reversible; OS X 10.10+ & iOS 8+). |
RotateByAngle !GFloat | Rotate by a relative value, in radians (reversible). |
RotateToAngle !GFloat | Rotate counterclockwise to an absolute angle, in radians (irreversible). |
RotateToAngleShortestUnitArc !GFloat !Bool | Rotate to an absolute angle. If second argument '== True', in the direction resulting in the smallest rotation; otherwise, interpolated (irreversible). |
SpeedBy !GFloat | Changes how fast the node executes actions by a relative value (reversible). |
SpeedTo !GFloat | Changes how fast the node executes actions to an absolute value (irreversible). |
ScaleBy !GFloat !GFloat | Relative change of x and y scale values (reversible). |
ScaleTo !GFloat !GFloat | Change x and y scale values to an absolute values (irreversible). |
ScaleXTo !GFloat | Change x scale value to an absolute value (irreversible). |
ScaleYTo !GFloat | Change y scale value to an absolute value (irreversible). |
Unhide | Makes a node visible (reversible; instantaneous; OS X 10.10+ & iOS 8+). |
Hide | Hides a node (reversible; instantaneous; OS X 10.10+ & iOS 8+). |
FadeIn | Changes the alpha value to 1.0 (reversible). |
FadeOut | Changes the alpha value to 0.0 (reversible). |
FadeAlphaBy !GFloat | Relative change of the alpha value (reversible). |
FadeAlphaTo !GFloat | Change the alpha value to an absolute value (irreversible). |
ResizeByWidthHeight !GFloat !GFloat | Adjust the size of a sprite (reversible). |
ResizeToHeight !GFloat | Change height of a sprite to an absolute value (irreversible). |
ResizeToWidth !GFloat | Change width of a sprite to an absolute value (irreversible). |
ResizeToWidthHeight !GFloat !GFloat | Change width and height of a sprite to an absolute value (irreversible). |
SetTexture Texture !Bool | Change a sprite's texture, maybe resizing the sprite (irreversible; instantaneous; ^without resizing only OS X 10.10+ & iOS 7.1+). |
AnimateWithTextures [Texture] !TimeInterval !Bool !Bool | Animate setting the textures, pausing by the given time interval between textures.
Rotate to an absolute angle. If second argument '== True', in the direction resulting
second |
ColorizeWithColor Color !GFloat | Animate a sprite's color and blend factor (irreversible). |
ColorizeWithColorBlendFactor !GFloat | Animate a sprite's blend factor (irreversible). |
PlaySoundFileNamed String !Bool | Play a sound, maybe waiting until the sound finishes playing (irreversible). |
RemoveFromParent | Removes the animated node from its parent (irreversible; instantaneous). |
RunActionOnChildWithName (Action node) String | Run an action on a named child node (reversible; instantaneous). |
Group [Action node] | Run all actions in the group in parallel (reversible). |
Sequence [Action node] | Run all actions in the group in sequence (reversible). |
RepeatActionCount (Action node) !Int | Repeat an action a fixed number of times (reversible). |
RepeatActionForever (Action node) | Repeat an action undefinitely (reversible). |
WaitForDuration !TimeInterval | Waits for the action's duration +/- half the given range value (irreversible). |
CustomAction (TimedUpdate node) | Repeatedly invoke the update function over the action duration (irreversible). |
data Action node
SpriteKit action.
NB: actionTimingFunction
not yet supported.
Action | |
|
data ActionTimingMode
Determines the temporal progression of an action.
type ActionTimingFunction = Float -> Float
Projects an input value between 0.0 and 1.0, inclusive, to another value between 0.0 and 1.0 to indicate the temporal progression of an action. The input 0.0 must be mapped to 0.0, and 1.0 to 1.0. Inbetween those bounds, the timing function can adjust the timing of the action.
action :: ActionSpecification node -> Action node
Construct an action.
Convenience functions to construct specifications of the same name
followPath :: Path -> Action node
followPathSpeed :: Path -> GFloat -> Action node
followPathAsOffsetOrientToPath :: Path -> Bool -> Bool -> Action node
rotateByAngle :: GFloat -> Action node
rotateToAngle :: GFloat -> Action node
rotateToAngleShortestUnitArc :: GFloat -> Bool -> Action node
fadeAlphaBy :: GFloat -> Action node
fadeAlphaTo :: GFloat -> Action node
resizeByWidthHeight :: GFloat -> GFloat -> Action node
resizeToHeight :: GFloat -> Action node
resizeToWidth :: GFloat -> Action node
resizeToWidthHeight :: GFloat -> GFloat -> Action node
setTexture :: Texture -> Action node
setTextureResize :: Texture -> Bool -> Action node
animateWithTexturesTimePerFrame :: [Texture] -> TimeInterval -> Action node
animateWithTextures
is a shorthand for convenience.
animateWithTextures :: [Texture] -> TimeInterval -> Action node
animateWithTextures
is a shorthand for convenience.
animateWithTexturesTimePerFrameResizeRestore :: [Texture] -> TimeInterval -> Bool -> Bool -> Action node
animateWithTexturesResizeRestore
is a shorthand for convenience.
animateWithTexturesResizeRestore :: [Texture] -> TimeInterval -> Bool -> Bool -> Action node
animateWithTexturesResizeRestore
is a shorthand for convenience.
colorizeWithColorColorBlendFactor :: Color -> GFloat -> Action node
colorizeWithColor
is a shorthand for convenience.
colorizeWithColor :: Color -> GFloat -> Action node
colorizeWithColor
is a shorthand for convenience.
colorizeWithColorBlendFactor :: GFloat -> Action node
playSoundFileNamedWaitForCompletion :: String -> Bool -> Action node
playSoundFileName
is a shorthand for convenience.
playSoundFileNamed :: String -> Bool -> Action node
playSoundFileName
is a shorthand for convenience.
removeFromParent :: Action node
runActionOnChildWithName :: Action node -> String -> Action node
group :: [Action node] -> Action node
groupActions
is to be symmetric with sequenceActions
.
groupActions :: [Action node] -> Action node
groupActions
is to be symmetric with sequenceActions
.
sequence :: [Action node] -> Action node
sequenceActions
is for convenience in the face of sequence
.
sequenceActions :: [Action node] -> Action node
sequenceActions
is for convenience in the face of sequence
.
repeatActionCount :: Action node -> Int -> Action node
repeatActionForever :: Action node -> Action node
waitForDuration :: Action node
waitForDurationWithRange :: TimeInterval -> Action node
customAction :: TimedUpdate node -> Action node
Perform the given update function once per frame for the given duration. If the duration is 0, the function is only invoked once.
The node on which the action is run is passed to the update function and gets replaced by the updated node.
FIXME: We need to document the tree merging algorithm.
Marshalling support (internal)
actionToSKAction :: Action node -> IO SKAction
data TimedUpdateBox node
TimedUpdateBox (TimedUpdate node) |
action_initialise :: IO ()
User events
Event information
data Event
Cocoa events.
NB: Not all event types are supported. Usually, because they would require functionality from other parts of Cocoa, which are not supported here (yet).
KeyEvent | |
| |
MouseEvent | |
| |
EnterExitEvent | |
| |
OtherEvent | |
|
data MouseEvent
data EnterExitEvent
CursorUpdate | FIXME: not yet supported |
Marshalling functions (internal)
event_initialise :: IO ()
Internal
spritekit_initialise :: IO ()