Now, we have done the first sample of touch tap, very easy, huh? Maybe you feel it's not exciting enough yet. The next example will be more interesting. The ball will randomly show up in every possible place within the touchscreen, and your job is to click the ball as soon as possible; every valid click will be counted and shown as scores at the top-left of the screen. The new sample's name is TouchTapRandomBall
.
Create a new Windows Phone 7 Game project in Visual Studio 2010 named TouchTapRandomBall
. Change the name from Game1.cs
to TouchTapRandomBallGame.cs
. Then add the Round.jpg
and gamefont.spritefont
to the associated content project:
1. The first operation is to add the lines as field variables:
GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D texRound; Rectangle HitRegion; bool isSelected = false; //start position of round, in the center of screen int positionX = 400; int positionY = 240; //random number...