1
# This code is so you can run the samples without installing the package
4
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
9
from cocos.director import director
10
from cocos.sprite import Sprite
12
from cocos.actions import MoveBy
14
# Try instantiating a TestNoBatch instead of a TestBatch for comparison
15
class TestNoBatch(cocos.layer.Layer):
17
super( TestNoBatch, self ).__init__()
18
x,y = director.get_window_size()
19
self.batch = cocos.cocosnode.CocosNode()
20
self.batch.position = 50, 100
21
self.add( self.batch )
23
sprite = Sprite('grossini.png')
24
sprite.position = (i/12)*30, (i%12)*25
25
self.batch.add( sprite )
26
self.batch.do(MoveBy((100, 100), 10))
28
class TestBatch(cocos.layer.Layer):
30
super( TestBatch, self ).__init__()
31
x,y = director.get_window_size()
32
self.batchnode = cocos.batch.BatchNode()
33
self.batchnode.position = 50,100
34
self.add(self.batchnode)
36
sprite = Sprite('grossini.png')
37
sprite.position = (i/12)*30, (i%12)*25
38
self.batchnode.add(sprite)
39
self.batchnode.do(MoveBy((100, 100), 10))
41
if __name__ == "__main__":
43
test_layer = TestBatch ()
44
main_scene = cocos.scene.Scene (test_layer)
45
director.show_FPS = True
46
director.run (main_scene)