/
test_transition_fadetr.py
48 lines (38 loc) · 1.22 KB
/
test_transition_fadetr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import division, print_function, unicode_literals
# This code is so you can run the samples without installing the package
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
#
testinfo = "t 0.1, s, t 0.5, s, t 1, s, t 1.5, s, t 2.1, s, q"
tags = "FadeTRTransition"
import cocos
from cocos.director import director
from cocos.actions import *
from cocos.layer import *
from cocos.scenes import *
from cocos.sprite import *
import pyglet
from pyglet.gl import *
class BackgroundLayer(cocos.layer.Layer):
def __init__(self):
super(BackgroundLayer, self).__init__()
self.img = pyglet.resource.image('background_image.png')
def draw( self ):
glColor4ub(255, 255, 255, 255)
glPushMatrix()
self.transform()
self.img.blit(0,0)
glPopMatrix()
def main():
director.init( resizable=True )
scene1 = cocos.scene.Scene()
scene2 = cocos.scene.Scene()
colorl = ColorLayer(32,32,255,255)
sprite = Sprite( 'grossini.png', (320,240) )
colorl.add( sprite )
scene1.add( BackgroundLayer(), z=0 )
scene2.add( colorl, z=0 )
director.run( FadeTRTransition( scene1, 2, scene2) )
if __name__ == '__main__':
main()