Put a field in your class to track how many clicks, it will look something like this:
public class Window
{
private int _clicks = 0;
private void redballoon_click(object sender, MouseButtonEventArgs e)
{
_clicks++;
}
}
Question
Ok I am new to silverlight in c# and I am building a game where balloons float around the screen and you get points for clicking one.
I so far have 5 balloons moving randomly around and I wish to have a mouse click even for all of them.
so far for a mouse click I have
C#
private void redballoon_click(object sender, MouseButtonEventArgs e)
{
// +1 to score array
}
XAML
<Image Height="53" HorizontalAlignment="Left" Margin="0,0,0,0" Name="red" Stretch="Fill" VerticalAlignment="Top" Width="48" Source="red.png" MouseLeftButtonDown="redballoon_click" Canvas.Left="194" Canvas.Top="161" RenderTransformOrigin="0.938,0.536" />
I would like some way of collecting the score for each click but I am very new and could do with some help.
Solution
Put a field in your class to track how many clicks, it will look something like this:
public class Window
{
private int _clicks = 0;
private void redballoon_click(object sender, MouseButtonEventArgs e)
{
_clicks++;
}
}