Now, we are going to create a new UserControl
to display the remaining lives in a gauge. We will use the previously created ScoreGauge
as a baseline to create this new gauge, making many changes. We will use our well-known blue alien as an icon to specify the remaining lives.
1. Open the project
3DInvadersSilverlight
in Visual Studio or Visual C#.2. Repeat the previously explained steps to create a new gauge based on
ScoreGauge.xaml
. Instead of usingBonusGauge
as the new name, useLifeGauge
.3. Open
LifeGauge.xaml.cs
(the C# code forLifeGauge.xaml
) and replace the textScoreGauge
withLifeGauge
in the first lines that define the class and the constructor, as shown in the following:public partial class LifeGauge : UserControl { public LifeGauge()
5. Add the following
public
method to change the number of icons shown to represent the remaining lives in the gauge:public void SetLives(int newLives) { WrapPanel...