Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 1.68 KB

step_03.rst

File metadata and controls

46 lines (33 loc) · 1.68 KB

Step 3 - Scene Object

Next we will add a Scene to our game. A Scene is a tool to manage a number of different SpriteLists by assigning each one a name, and maintaining a draw order.

SpriteLists can be drawn directly like we saw in step 2 of this tutorial, but a Scene can be helpful to handle a lot of different lists at once and being able to draw them all with one call to the scene.

To start with we will remove our sprite lists from the __init__ function, and replace them with a scene object.

../../../arcade/examples/platform_tutorial/03_scene_object.py

Next we will initialize the scene object in the setup function and then add the SpriteLists to it instead of creating new SpriteList objects directly.

Then instead of appending the Sprites to the SpriteLists directly, we can add them to the Scene and specify by name what SpriteList we want them added to.

../../../arcade/examples/platform_tutorial/03_scene_object.py

Lastly in our on_draw function we can draw the scene.

../../../arcade/examples/platform_tutorial/03_scene_object.py

Source Code

../../../arcade/examples/platform_tutorial/03_scene_object.py