~facundo/enjuewemela/trunk

« back to all changes in this revision

Viewing changes to enjuewemela/cocos/test/test_batch.py

  • Committer: facundo at com
  • Date: 2010-11-20 01:42:31 UTC
  • mfrom: (62.1.3 lint-issues)
  • Revision ID: facundo@taniquetil.com.ar-20101120014231-b2tkyc3mwr84ggcc
Project reorder and lint issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This code is so you can run the samples without installing the package
2
 
import sys
3
 
import os
4
 
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
5
 
#
6
 
 
7
 
 
8
 
import cocos
9
 
from cocos.director import director
10
 
from cocos.sprite import Sprite
11
 
import pyglet
12
 
from cocos.actions import MoveBy
13
 
 
14
 
# Try instantiating a TestNoBatch instead of a TestBatch for comparison
15
 
class TestNoBatch(cocos.layer.Layer):
16
 
    def __init__(self):
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 )
22
 
        for i in range(216):
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))
27
 
 
28
 
class TestBatch(cocos.layer.Layer):
29
 
    def __init__(self):
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)
35
 
        for i in range(216):
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))
40
 
 
41
 
if __name__ == "__main__":
42
 
    director.init()
43
 
    test_layer = TestBatch ()
44
 
    main_scene = cocos.scene.Scene (test_layer)
45
 
    director.show_FPS = True
46
 
    director.run (main_scene)
47