public void playGame() { gameState = 1;//进入游戏状态 Components.RemoveAt(0); Components.Add(gameComponent); Chapters.getInstance().init(); ScoreBoard.getInstance().init(); gameComponent.clear(); PlayerBall.init(new Vector2(100, 100), 6, Resourse.getInstance().playerBallTexture, 50); bgm.Play(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } KeyboardState keystate = Keyboard.GetState(); switch (gameState) { case 0: //如果在开始画面 if (keystate.IsKeyDown(Keys.Enter)) { gameState = 1; //进入游戏状态 Components.RemoveAt(0); Components.Add(gameComponent); PlayerBall.init(new Vector2(100, 100), 6, Resourse.getInstance().playerBallTexture, 50); } break; case 1: break; case 2: case 3: gameState = 0; Components.RemoveAt(0); Components.Add(startComponent); PlayerBall.init(new Vector2(100, 100), 6, Resourse.getInstance().playerBallTexture, 50); Chapters.getInstance().init(); gameComponent.clear(); break; } // TODO: Add your update logic here base.Update(gameTime); }