On 28/11/2009, at 4:34 AM, flx wrote:

> 2009/11/27 Richard Jones <[email protected]>:
>> I'll send my full code when I can then because with the change in
>> question you should be able scale way higher than even 1000...
>> 
> I'll apreciate it

Attached is the complete modified script that uses a single batch instead of 
one per sprite.

BTW, I didn't actually explain it before but this allows OpenGL to do all the 
culling instead of having to do it manually in your program. OpenGL is smart 
enough to not bother rendering offscreen objects.


      Richard

--

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.


import cocos
from cocos import batch
from cocos.actions import *

class TLayer(cocos.layer.Layer):
   is_event_handler = True
   def __init__(self):
       cocos.layer.Layer.__init__(self)
       b = batch.BatchNode()
       self.add(b)
       for i in range(1000):
           b.add(cocos.sprite.Sprite('fire.png', (100 * i, 100 * i)))

   def on_mouse_scroll(self, x, y, dx, dy):
       self.do(ScaleBy(0.25 * dy + 1.0, 0.5))

   def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
       self.x += dx
       self.y += dy

if __name__ == "__main__":
   cocos.director.director.init(vsync=True)
   cocos.director.director.show_FPS=True
   cocos.director.director.run(cocos.scene.Scene(TLayer()))

Reply via email to