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

Menus


It's time we made some menus. If we want menus, we need buttons to press. But before we make the buttons, we need to perform the following steps:

  1. Because a button uses touch to determine if it's being pressed, we need to add the current touch state to the render context so all objects have the latest touch state. We do this by adding an extra property to the render context and by setting the latest touch state in the Update method of the scene manager.

    // Extra property of the render context
    public TouchCollection TouchPanelState { get; set; }
    
    // Update the TouchPanelState in the 
    // Update of the Scene Manager
    RenderContext.TouchPanelState = TouchPanel.GetState();
  2. Add an extra HitTest method to our GameObject2D. This because touch returns a point instead of a rectangle. We can check if a point is in a rectangle by using the Contains method. Note that we use an extra argument that specifies whether we want to test all the children. This is not always the case, as you will see in the...

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