
Hey,
I would like to write FII bindings in haskell for cocos2d-x
(http://www.cocos2d-x.org/), which is a C++ library.
Since I have little experience with this, I would like some feedback
before I discover that concept is bad half way.
In cocos2d there is a base class with much functionality: CCNode
Many classes derive from it (i.E. CCLayer) and use the virtual functions
of CCNode (i.E. setPosition).
How do I map this to haskell?
The general Idea:
I have a typeclass, in which everything that is derived from CCNode is
an instance:
class NodeDerived a where
toNode :: a -> Node
setPosition :: a -> (Double,Double) -> IO ()
setPosition a pos = setNodePosition (toNode a) pos
instane NodeDerived Layer where
toNode = layerToNode
and layerToNode :: Layer -> Node would be implemented in C++ as:
CCNode* layerToNode(CCLayer* l) { return dynamic_cast