File tree Expand file tree Collapse file tree 6 files changed +31
-1
lines changed Expand file tree Collapse file tree 6 files changed +31
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Here we will have the same starting code as we did in the last tutorial, except with a few different imports
2
+
3
+ import cocos
4
+ from cocos .text import Label
5
+ from cocos import scene
6
+ from cocos .layer import Layer
7
+ from cocos .director import director
8
+ from cocos .sprite import Sprite
9
+
10
+
11
+ class Actors (Layer ):
12
+ def __init__ (self ):
13
+ super (Actors , self ).__init__ ()
14
+
15
+ # Here is where the code starts to get different
16
+ # Instead of text, I create a sprite object
17
+ # Also unlike last time, I added the sprite to the object instead of making it local
18
+ # This is useful if you want to access it in other functions, like I will show in the next tutorial
19
+ self .actor = Sprite ('assets/img/grossini_dance_08.png' )
20
+
21
+ # Then I add it to the layer, similar to the text
22
+ self .actor .position = 320 , 240
23
+
24
+ # And lastly I add it to the layer. Standard stuff
25
+ self .add (self .actor )
26
+
27
+ # Now I initialize the director and run the scene just like before
28
+ director .init ()
29
+ director .run (scene .Scene (Actors ()))
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 4
4
Here is the order which the tutorial follows:
5
5
6
6
1 . Getting Started (getting_started.py)
7
- 2 . Basic Actions (actions.py)
7
+ 2 . Adding Actors (actors.py)
8
+ 3 . Basic Actions (actions.py)
You can’t perform that action at this time.
0 commit comments