Controlling the size of images is a basic technique in Windows Phone 7 XNA programming. Mastering this technique will help you implement many special visual effects in 2D. In this recipe, you will learn how to zoom an image in and out for a special visual effect. As an example, the image will jump up to you and go back. In the jumping phase, the image will fade out gradually. When the image becomes transparent, it will fall back with fading in.
The following mandatory steps will lead you to complete the recipe:
1. Create a Windows Phone Game in Visual Studio 2010 named
ImageZoomInOut
, changeGame1.cs
toImageZoomGame.cs
. Then add theNext.png
file from the code bundle to the content project. After the preparation work, insert the following code to the field of theImageZoomGame
class:// Image texture object Texture2D texImage; // Image position Vector2 Position; // The scale factor float scale = 1; // The rotate factor float rotate = 0; // Alpha value for controlling...