public void checkTouch() { foreach(TouchLocation location in TouchPanel.GetState()) { if (location.State == TouchLocationState.Pressed && !isReady && !isGameOver && !isTouchGround) { isReady = true; StupidBird.Move(); } if (location.State == TouchLocationState.Pressed && isReady && !isGameOver && !isTouchGround) { soundWing.Play(); StupidBird.isUp = true; StupidBird.ResetMove(); } Vector2 Position = location.Position; if ((isGameOver || isTouchGround) && (Position.Y >= 400) && (Position.Y <= 400 + BtnRetry.Height) && (Position.X >= (480 - BtnRetry.Width) / 2) && (Position.X <= (480 + BtnRetry.Width) / 2)) { isReady = false; isGameOver = false; isTouchGround = false; score = 0; StupidBird.Position = new Vector2(100f, 360f); StupidBird.ResetMove(); StupidBird.isTouchGround = false; pipeControl = new PipeControl(Content, spriteBatch); } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here bg_game1 = Content.Load<Texture2D>("img/bg_game1"); bg_game = Content.Load<Texture2D>("img/bg_game"); soundPoint = Content.Load<SoundEffect>("sound/sfx_point"); soundWing = Content.Load<SoundEffect>("sound/sfx_wing"); soundDie = Content.Load<SoundEffect>("sound/sfx_die"); soundhit = Content.Load<SoundEffect>("sound/sfx_hit"); footer = new Footer(Content, spriteBatch); pipeControl = new PipeControl(Content, spriteBatch); bird1 = Content.Load<Texture2D>("img/bird1"); fontScore = Content.Load<SpriteFont>("SpriteFont1"); StupidBird = new Bird(Content, spriteBatch); BtnRetry = Content.Load<Texture2D>("img/btn-play"); GameoverTexture = Content.Load<Texture2D>("img/gameover"); }