mchakravarty / haskellspritekit Goto Github PK
View Code? Open in Web Editor NEWHaskell binding to Apple's SpriteKit framework
License: Other
Haskell binding to Apple's SpriteKit framework
License: Other
If actions are used repeatedly, it is more efficient to create the action objects once and run them on multiple nodes. To do this in the Haskell binding, use stable names to identify identical actions (actually action trees) and reuse them.
(We need to be careful to free them after a while of not being used, though.)
When the contact handler returns an entirely new node in the second or third component of the result triple, that new nodes does seem to get ignored.
At the moment, it makes no sense to make the fields of Node
components strict as we exploit laziness for lazy marshalling back to Haskell. However, the following would be even better.
Node
components strict (at least those of elementary type, but maybe also some frequently modified ones of Point
, Rect
, and so on types).Scene
. (Maybe even do it first for Scene
.)This balances thunk creation and entering overhead with the overhead of marshalling elementary values that are not ending up being changed.
spriteWithXYZ
functions actually ought to be called spriteNodeWithXYZ
.SKNode(fileNamed:)
.hsproj
project resources?I'm playing around with the SpriteKit binding trying to learn and understand the basics. I have the following simple scene:
import Graphics.SpriteKit
moveThisNode = (moveTo (Point 200 200)) {actionDuration = 10}
aSprite = (spriteWithColorSize redColor (Size 2 2)) {
nodePosition = Point 125 125,
nodeSpeed = 1,
nodeActionDirectives = [
RunAction moveThisNode Nothing
],
nodePaused = True
}
sceneWithSprite = (sceneWithSize (Size 250 250)) {
scenePaused = True,
sceneChildren = [aSprite]
}
Since both, the node and the scene are set to be paused, I would expect the sprite not to move.
However, when I render the sceneWithSprite
in Haskell for Mac, I clearly see the little red sprite moving.
Am I doing something wrong? Is my understanding of paused wrong?
Consider this alternative scheme (and adapt the todo items below):
SKNode
representation keeps a stable pointer to the Haskell representation it originates from. (Then, we can probably get rid of the special case of how we are doing that for scene nodes right now and we don't need to have the "haskellUserData"
entry in SKNode
s userData
as this is subsumed bu a reference to the entire Haskell representation.)SKNode
to Haskell.SKNode
representation, we always determine the to be updated delta by comparing to the Haskell representation refereed to be the SKNode
(that crucial depends on the previous point).SKNode
to invoke methods, such as frame
or calculateAccumulatedFrame
(assuming nodeForeign
is set), we update the reference to the Haskell representation, which then serves as the delta for the next Haskell to SKNode
marshalling — saving work when we call multiple functions, such as frame
or when the Haskell representation is passed back unchanged as a result node.addChildren
is quite inefficient for large arrays of children. We should use sets for the containment testing when the arrays get bigger.addChildren
doesn't generally preserve the order of the children (wrt to the order in the Haskell structure). This is bad as the drawing order depends on the order of the children.Node.addChildren
and related functions. When we update an existing SKNode
tree with Haskell-side changes, currently, the whole tree gets traversed if the nodeChildren
field of the root changed at all. This is quite inefficient on large trees. It would be better, while inspecting the individual children to see whether some children didn't change at all and then prune the traversal using that information.I am having a problem compiling the HaskellSprite kit in Xcode 9.1 with GHC v. 8.2.2.
The error is placed below:
Showing Recent Messages
[ 8 of 14] Compiling Graphics.SpriteKit.Types ( Graphics/SpriteKit/Types.hs, /Users/braedenfoster/Library/Developer/Xcode/DerivedData/HaskellSpriteKit-ckqakbbckyvankhijtgdgqnstbxs/Build/Intermediates.noindex/SwiftMigration/HaskellSpriteKit/Intermediates.noindex/HaskellSpriteKit.build/Debug/HaskellSpriteKit.build/spritekit/build/Graphics/SpriteKit/Types.o )
Graphics/SpriteKit/Types.hs:395:19: error:
Not in scope: type constructor or class ‘GHC.Any’
Module ‘GHC.Prim’ does not export ‘Any’.
|
395 | newtype Any = Any GHC.Any
| ^^^^^^^
cabal: Leaving directory 'HaskellSpriteKit/spritekit'
cabal: Error: some packages failed to install:
spritekit-0.9.0.2-CQBFv3qNfz48eVFPtHanfT failed during the building phase. The
exception was:
ExitFailure 1
cabal install failed
The haskellScenePtr
refers to the Haskell version of a scene including the scene's children. Those children may, however, be outdated when we get back to sceneUpdate
on the next frame as both actions and contact handlers may have changed arbitrary children in arbitrary ways.
haskellScenePtr
at the start of a frame (using lazy marshalling as usual).See definition of Action
in Types.hs
.
Currently, the build system doesn't build a profiling flavour of spritekit
. This is as the unique identifier names generate by language-c-inline
for 'hswrapper's get different names in a profiling build, and so, would need a different variant of the wrapper Objective-C code.
This is really an infelicity of language-c-inline
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.