Kinect Click counter function
- by Sweta Dwivedi
So i have the following kinect click function which will check if the hand is within the bounds then it will click with a counter . . however there is a slight problem . .the first few button clicks work fine.. but after it clicks one of the buttons it changes the game state and immediately clicks the other button without the counter reaching 200. . .
Kinect click is a method in the button class. . .and each button inside a list can access the Kinect click method. . .
public bool KinectClick(int x,int y)
{
if ((x >= position.X && x <= position.X + position.Width) && (y >= position.Y && y <= position.Y + position.Height))
{
counter++;
if (counter > 200)
{
counter = 0;
return true;
}
}
else
{
counter = 0;
}
return false;
}
I call to check if this property is true in the Game update method to act as a button click. .
foreach(Button g_t in Game_theme)
{
if ((g_t.KinectClick(x_c, y_c) == true || g_t.ButtonClicked() == true) && g_t.name == "animoe")
{
Selected_anim = true;
currentGameState = GameState.InGame;
}
if ((g_t.KinectClick(x_c, y_c) == true || g_t.ButtonClicked() == true) && g_t.name == "planet")
{
Selected_planet = true;
currentGameState = GameState.InGame;
}