forked from los-cocos/cocos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_camera_orbit.py
More file actions
57 lines (42 loc) · 1.58 KB
/
test_camera_orbit.py
File metadata and controls
57 lines (42 loc) · 1.58 KB
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
49
50
51
52
53
54
55
56
57
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 2, s, t 4, s, t 6, s, t 8, s, t 10, s, t 12, s, t 14, s, t 16.1, s, q"
tags = "OrbitCamera"
import pyglet
import cocos
from cocos.director import director
from cocos.actions import *
from cocos.layer import *
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 )
#director.set_depth_test()
main_scene = cocos.scene.Scene()
background = BackgroundLayer()
color = ColorLayer(255,32,32,128)
main_scene.add( background, z=0 )
main_scene.add( color, z=1 )
# use the remaining grid and move it's camera
rot = OrbitCamera( angle_x=45, angle_z=0, delta_z=360, duration=8 )
rot2 = OrbitCamera( radius=2, delta_radius=-1, angle_x=0, angle_z=0, delta_z=360, duration=8 )
# In real code after a sequence of grid actions the StopGrid() action
# should be called. Omited here to stay in the last grid action render
background.do( rot + Reverse(rot) )
color.do( rot2 + Reverse(rot2) )
director.run (main_scene)
if __name__ == '__main__':
main()