Cocos (and pyglet on which Cocos is based) do no culling of off-screen
sprites because they incur no performance penalty until you start
talking about perhaps millions of them. Your example has only a
thousand.
Your low FPS rate is likely due to some other cause. If your
application isn't doing anything (neither animating nor responding to
user events) then pyglet / cocos will not update the screen. Or
perhaps your video driver needs updating.
Richard
Posted from my superabacus
On 27/11/2009, at 4:25 AM, flx <[email protected]> wrote:
> On Nov 25, 6:42 pm, flx <[email protected]> wrote:
>> I've been trying a litle cocos2d and I'm loving it, but I've found
>> that sprites seems to be drawing even if they're not inside the
>> visible area of a layer. How can i prevent them from update or draw
>> if
>> they're outside the viewport?
>>
>> Here is some test code i was trying with, i'm sure that i've been
>> doing things the wrong way so help's apreciated.
>>
>> --
>>
>> import sys
>> import os
>> sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
>>
>> import cocos
>> from cocos.actions import *
>>
>> class TLayer(cocos.layer.Layer):
>> is_event_handler = True
>> def __init__(self):
>> cocos.layer.Layer.__init__(self)
>> self.sprites = []
>> for i in range(1000):
>> s = cocos.sprite.Sprite('fire.png', (100 * i, 100 * i))
>> self.sprites + [s]
>> self.add(s);
>>
>> 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
>>
>> layer = TLayer()
>>
>> cocos.director.director.run (cocos.scene.Scene(layer))
>
> In the test only 3 or 4 images should be rendered, but it runs at
> ~3fps no matter how many images are displayed
>
> Btw, is there someone still using this framework? it seems that only
> the iphone version is active :(
>
> --
>
> 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
> .
>
>
--
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.