Your project manager wants you to animate the perspective transform applied to the video while it is being reproduced.
We are going to add a StoryBoard in XAML code to animate the PlaneProjection instance:
<PlaneProjection x:Name ="proIntroduction" RotationX="-40"
RotationY="15" RotationZ="-6" LocalOffsetX="-70"
LocalOffsetY="-105" />
introductionSB.Begin();
Now, the projection that shows the video is animated while the video is being reproduced.
First, we added a name to the existing PlaneProjection (proIntroduction). Then, we were able to create a new StoryBoard with a DoubleAnimation instance as a child, with the StoryBoard‘s TargetName set to proIntroduction and its TargetProperty set to RotationX. Thus, the DoubleAnimation controls proIntroduction‘s RotationX value. The RotationX value will go from -40 to 0 in five seconds—the same time as the video’s duration:
From="-40" To="0" Duration="0:0:5"
The animation will run once (1x) and it won’t reverse its behavior:
AutoReverse="False" RepeatBehavior="1x"
We added the StoryBoard inside
introductionSB.Begin();
We can define StoryBoard instances and different Animation (System. Windows.Media.Animation) subclasses instances as DoubleAnimation, using XAML code. This way, we can create amazing animations for many properties of many other UIElements defined in XAML code.
When the game starts, there is an undesired side effect. The projected video appears in the right background, as shown in the following screenshot:
This usually happens when working with projections. Now, we are going to solve this small problem:
cnvVideo.Visibility = Visibility.Collapsed;
Now, once the video finishes its reproduction and associated animation, we have hidden the Canvas that contains it. Hence, there are no parts of the previous animation visible when the game starts.
Great games have appealing background music. Now, we are going to search and add background music to our game:
As with other digital content, sound and music have a copyright owner and a license. Hence, we must be very careful when downloading sound and music for our games. We must read licenses before deploying our games with these digital contents embedded.
You can use any other MP3 sound for this exercise. The aforementioned MP3 demo is not included in the accompanying source code.
// Background music
MediaElement backgroundMusic = new MediaElement();
LayoutRoot.Children.Add(backgroundMusic);
backgroundMusic.Volume = 0.8;
backgroundMusic.Source =
new Uri("Media/distorted_velocity._1.mp3", UriKind.Relative);
backgroundMusic.Play();
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…