Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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;

                        }
share|improve this question
please, consider posting the whole relevant code. Whad does ButtonClcked() do? – Heisenbug Oct 11 '12 at 11:21
Its a huge huge code.. so i thought i'd post only the relevant part .. Button click is just checking mouse click input – Sweta Dwivedi Oct 11 '12 at 11:22
So are you using both mouse and kinect to press a button? – Heisenbug Oct 11 '12 at 11:23
I want the user to be able to use kinect or mouse input (one of them) to be able to click.. and i'm only using once function at a time – Sweta Dwivedi Oct 11 '12 at 11:29
I really can't say which is your problem. Basically the counter mechanism is reasonable and looks right. The problem could be somewhere else. Personally I found difficult to manage both Kinect and Mouse at the same time. If you want to look some code, I've online a little project showing features like this. The code is a bit messed up, but eventually could be an useful starting point: bugamove.codeplex.com. – Heisenbug Oct 11 '12 at 11:43
show 4 more comments

closed as too localized by Tetrad Mar 12 at 4:58

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.