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))
--
--
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.