For a better view, go to http://www.youtube.com/watch?v=pdnvYt89KyQ
Great! It worked. Ok, so here's the title page I've made for the game. Currently I'm still trying to get my head around what needs to be done next. I can make the character move, and crouch. Next I'll have to make a little dog character so I can start doing some basic AI.
Using WPF is great for static or shape based animations, but in terms of anything sprite-based, the WPF extras don't really help you out much. If you know your WPF, you'll probably see the types of animations I'm using:
TranslateTransforms - For the code lines. You use these to move things. In the video I use the .BeginTime and .AutoReverse properties of the attached DoubleAnimation to set up how the animation works. This is a bit harder than a simple DoubleAnimation. You need to create a TranslateTransfrom and attach a DoubleAnimation to it.
DoubleAnimation - This was used to change the opacity of the green rectangle that covers the code.
Once you have created a rectangle, you attach a DoubleAnimation object to the Rectangle's OpacityProperty property, and you're away.
Here's the code I used to do that:
XAML
<Rectangle Margin="0,-9,0,0" Name="titleRect" Stroke="Black" Fill="Green" Grid.RowSpan="2" />
C#
DoubleAnimation gridOpacity = new DoubleAnimation();
gridOpacity.From = 0;
gridOpacity.To = 1;
gridOpacity.RepeatBehavior = RepeatBehavior.Forever;
gridOpacity.AutoReverse = true;
gridOpacity.Duration = TimeSpan.Parse("0:0:5");
titleRect.BeginAnimation(Rectangle.OpacityProperty, gridOpacity);
If you want to see the stuff I did for TranslateTransforms, let me know, I'll be happy to share.
Comments