Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building your First Mobile Game using XNA 4.0

You're reading from   Building your First Mobile Game using XNA 4.0 A fast-paced, hands-on guide to building a 3D game for the Windows Phone 7 platform using XNA 4.0

Arrow left icon
Product type Paperback
Published in Jan 2013
Publisher Packt
ISBN-13 9781849687744
Length 158 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Thomas Goussaert Thomas Goussaert
Author Profile Icon Thomas Goussaert
Thomas Goussaert
Brecht Kets Brecht Kets
Author Profile Icon Brecht Kets
Brecht Kets
Arrow right icon
View More author details
Toc

Scene manager


So now we have a basic scene graph. The only problem is switching between scenes. If we want to switch between the 2D and 3D scene, we need to change a lot of code in our game class. And that's only with two scenes; games tend to have a lot more. It would be a lot simpler to be able to add multiple scenes to our game and just select an active one. It's time we did just that.

The GameScene

If we want to create a scene manager, we first need a class that will represent a scene.

Properties

Let us start by identifying the properties of a scene. A scene should have a name, along with a list of 2D game objects and a list of 3D game objects.

public string SceneName { get; private set; }
public List<GameObject2D> SceneObjects2D { get; private set; }
public List<GameObject3D> SceneObjects3D { get; private set; }

Constructor

The constructor will have one argument of type string, being the name of the scene. In the body, we will set the name, and create new containers for our game...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image