public void Update(GameTime gameTime) { #region button algorithim to change color // a button if (fingerLocations[0].Intersects(buttonsRect[0])) { buttonColor[0] = Color.Black; leapButtons = LeapButtons.A; } else { buttonColor[0] = Color.White; } // b button if (fingerLocations[0].Intersects(buttonsRect[1])) { buttonColor[1] = Color.Black; leapButtons = LeapButtons.B; } else { buttonColor[1] = Color.White; } // x button #endregion }
public LeapMotionButtons() { // leap collisions redone fingerLocations = new Rectangle[5]; fingerLocations[0] = new Rectangle(800, 600, 128, 128); fingerLocations[1] = new Rectangle(0, 0, 128, 128); fingerLocations[2] = new Rectangle(0, 0, 128, 128); fingerLocations[3] = new Rectangle(0, 0, 128, 128); fingerLocations[4] = new Rectangle(0, 0, 128, 128); // leap collision leapCollision = new Rectangle(0, 0, 128, 128); // TODO: Add your initialization logic here storedGameTime = new GameTime(); buttons = new Texture2D[2]; /* for (int i = 0; i < 4; i++) * { * buttons = new Texture2D[i]; * }*/ buttonsRect = new Rectangle[2]; buttonsRect[0] = new Rectangle(100, 300, 256, 256); buttonsRect[1] = new Rectangle(400, 300, 256, 256); buttonColor = new Color[2]; buttonColor[0] = Color.White; buttonColor[1] = Color.White; leapButtons = LeapButtons.nohit; }
public void Update(GameTime gameTime) { #region button algorithim to change color // a button if (fingerLocations[0].Intersects(buttonsRect[0])) { buttonColor[0] = Color.Black; leapButtons = LeapButtons.A; ScreenManager.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.a; ScreenManager.resumevideogame.IsHit = true; } else { buttonColor[0] = Color.White; } // b button if (fingerLocations[0].Intersects(buttonsRect[1])) { buttonColor[1] = Color.Black; leapButtons = LeapButtons.B; ScreenManager.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.b; ScreenManager.resumevideogame.IsHit = true; } else { buttonColor[1] = Color.White; } // x button if (fingerLocations[0].Intersects(buttonsRect[2])) { buttonColor[2] = Color.Black; leapButtons = LeapButtons.X; ScreenManager.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.x; ScreenManager.resumevideogame.IsHit = true; } else { buttonColor[2] = Color.White; } // y button if (fingerLocations[0].Intersects(buttonsRect[3])) { buttonColor[3] = Color.Black; leapButtons = LeapButtons.Y; ScreenManager.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.y; ScreenManager.resumevideogame.IsHit = true; } else { buttonColor[3] = Color.White; } #endregion }
public void Update(GameTime gameTime) { #region button algorithim to change color // a button if (fingerLocations[0].Intersects(buttonsRect[0]) || fingerLocations[1].Intersects(buttonsRect[0]) || fingerLocations[2].Intersects(buttonsRect[0]) || fingerLocations[3].Intersects(buttonsRect[0]) || fingerLocations[4].Intersects(buttonsRect[0])) //if (fingerLocations[0].Intersects(buttonsRect[0])) { if (SoundState.Stopped == soundInstanceButtonA.State) { soundInstanceButtonA.Play(); } buttonColor[0] = Color.Black; leapButtons = LeapButtons.A; ScreenManager.Instance.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.a; ScreenManager.Instance.resumevideogame.IsHit = true; } else { buttonColor[0] = Color.White; } // b button if (fingerLocations[0].Intersects(buttonsRect[1]) || fingerLocations[1].Intersects(buttonsRect[1]) || fingerLocations[2].Intersects(buttonsRect[1]) || fingerLocations[3].Intersects(buttonsRect[1]) || fingerLocations[4].Intersects(buttonsRect[1])) { if (SoundState.Stopped == soundInstanceButtonB.State) { soundInstanceButtonB.Play(); } buttonColor[1] = Color.Black; leapButtons = LeapButtons.B; ScreenManager.Instance.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.b; ScreenManager.Instance.resumevideogame.IsHit = true; } else { buttonColor[1] = Color.White; } // x button if (fingerLocations[0].Intersects(buttonsRect[2]) || fingerLocations[1].Intersects(buttonsRect[2]) || fingerLocations[2].Intersects(buttonsRect[2]) || fingerLocations[3].Intersects(buttonsRect[2]) || fingerLocations[4].Intersects(buttonsRect[2])) { if (SoundState.Stopped == soundInstanceButtonX.State) { soundInstanceButtonX.Play(); } buttonColor[2] = Color.Black; leapButtons = LeapButtons.X; ScreenManager.Instance.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.x; ScreenManager.Instance.resumevideogame.IsHit = true; } else { buttonColor[2] = Color.White; } // y button if (fingerLocations[0].Intersects(buttonsRect[3]) || fingerLocations[1].Intersects(buttonsRect[3]) || fingerLocations[2].Intersects(buttonsRect[3]) || fingerLocations[3].Intersects(buttonsRect[3]) || fingerLocations[4].Intersects(buttonsRect[3])) { if (SoundState.Stopped == soundInstanceButtonY.State) { soundInstanceButtonY.Play(); } buttonColor[3] = Color.Black; leapButtons = LeapButtons.Y; ScreenManager.Instance.resumevideogame.Whichbuttonhit = ResumeVideoGame.WhichButtonHit.y; ScreenManager.Instance.resumevideogame.IsHit = true; } else { buttonColor[3] = Color.White; } #endregion }