Kinect Click counter function
Posted
by
Sweta Dwivedi
on Game Development
See other posts from Game Development
or by Sweta Dwivedi
Published on 2012-10-11T06:30:22Z
Indexed on
2012/10/11
9:53 UTC
Read the original article
Hit count: 278
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;
}
© Game Development or respective owner