O'Reilly logo

3D Game Development with Microsoft Silverlight 3 Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—showing and updating multiple gauges

Finally, it is time to combine the three new gauges with the 3D scenes and add the necessary update logic to the game.

  1. Open the project 3DInvadersSilverlight in Visual Studio or Visual C#.
  2. Open MainPage.xaml.cs the C# code for MainPage.xaml.
  3. Add the following private variable in the public partial class MainPage : UserControl, to hold instances for each new UserControl subclass that defines a gauge:
    private BonusGauge _bonusGauge;
    private FuelGauge _fuelGauge;
    private LifeGauge _lifeGauge;
    
  4. Add the following public method to update the values shown in the different gauges:
    public void SetBonus(int newBonus) { _bonusGauge.SetBonus(newBonus); } public void SetFuelLevel(int newFuelLevel) { _fuelGauge.SetFuelLevel(newFuelLevel); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required