[MacRuby-devel] MacRuby and Cocos2D

Rolando Abarca rolando at gamesforfood.com
Thu Jan 13 05:32:10 PST 2011


hi all,

I'm having some fun with Cocos2D[1] Mac Version and MacRuby. Some time
ago I wrote ruby bindings for the iPhone version[2], but MacRuby makes
those bindings unnecessary (at least for mac).
So far everything works great! The only problem I'm having so far is
in cases like this:

{{{
some_node = CCSprite.spriteWithFile("some_file.png")
self.addChild(some_node)
}}}

If I do the above, the object will get GCd by the ruby VM (I'm
guessing), but the object should still live the Obj-C world
(internally, each Cocos2D node keeps its children in an array, where
they are retained in the addChild method).
So far, I'm bypassing this by declaring each child an instance
variable, but I'm pretty sure there must be another way... Any idea of
how to overcome this problem?
Btw: cocos2d works using the old retain/release memory management
system, even in the Mac version.

Thanks!,

[1]: http://www.cocos2d-iphone.org
[2]: https://github.com/funkaster/ShinyCocos
-- 
Rolando Abarca M.
Games For Food S.p.A.
http://www.gamesforfood.com
Phone: +1 (408) 345-5433


More information about the MacRuby-devel mailing list