First of all, congratulations on the new release candidate!  I'm
downloading it as we speak to play around.  :)

I've been fooling around with the tile system to create a simple 2D
tile-based game, and I noticed that the current method employed by the
MapLayer class appears to be far less efficient than it needs to be.
Currently, whenever the focus point changes for the layer, it
recomputes all the viewable tiles and discards the Sprites which are
no longer viewable while creating new ones for the ones that came into
view.  I could be wrong, but this seems totally unnecessary to me.  By
changing the logic to initialize every tile in the layer upon
instantiation and not call _update_sprite_set every time the view
changes, I went from about 66-68% CPU usage down to 11-13% in my test
scene with several parallax scrolling layers.  This keeps all the
sprites in memory, but the actual textures are already loaded anyway
via the Tile objects, so I don't think this is a concern.

As I understand it, OpenGL is smart enough not to draw the stuff that
isn't actually visible on the screen, and this appears to be far more
CPU efficient.  This does require a slight change for the debug
information, in that you need to reinitialize all the tiles if the
debug flag changes, but that shouldn't be a concern in a final release
anyway.  Maybe there is some reason I'm not aware of that the current
way is better for, but as far as I can tell, this way works exactly
the same and uses much less CPU.

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en.

Reply via email to