Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetPointerPressed()

Author
Message
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 13th Dec 2015 23:43
I seem to be getting what seems like "switch bounce" when using GetPointerPressed(). I bypass code in the main loop until the the left mouse button is pressed, then process based on where the mouse is pointing. However, the code in question loops through several times with merely one mouse click. This is happening in Tier 2 only. The original Tier 1 code does not do this.

Could the GetMousePointer() function not be resetting??

Converting to C++ is driving me insane. Everything is working great until I try to play the puzzles in my game. I am trying to modify the original code to fit with the main loop of the template. It seemed to me just a matter of code logic, but I am getting really weird phenomenon that should not be happening based on my code.

Why would one press of the mouse button allow more than one loop? Should not the value of GetPointerPressed() go back to zero as soon as I am not pressing the button??
home.wavecable.com/~mindsclay
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 14th Dec 2015 00:00
This is what I do but the code inside the IF statement (the second one) keeps executing more than once...


This is inside the main loop of the supplied template. The second IF statement should not be executing when MainLoop.loopToggle1 is set to zero. It gets set to 1 when the mouse button is pressed. So GetMousePointer() must be getting set to 1 after the initial one press.
home.wavecable.com/~mindsclay
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 14th Dec 2015 00:20
Never mind.

I just can't get my brain to wrap around how Tier 1 code can work even if there are flaws in the code.
home.wavecable.com/~mindsclay
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 14th Dec 2015 00:20
hmm, maybe u used this MainLoop.loopToggle1 anywhere. try using breakpoints and step through.
u can make a function to set this value + a debug log
void loopToggle(int onOff)
{
MainLoop.loopToggle1 = onOff;
std::cout << "loopToggle\n";
}

or your mouse is out of order.
or its a bug in agk, try other version.
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 14th Dec 2015 09:26
Input works differently in tier 2. The agk main loop in core.cpp is what collects the input so this must be allowed to run each frame or your input will not update.

Not sure how tier 1 does it, perhaps sync() also updates the input? But with tier 2 you may need to restructure your code so that main loop is always ticking over.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Dec 2015 23:11
In Tier 1 the Sync() command handles all inputs, outputs, physics updates, etc..

In Tier 2, it will update the display and physics anywhere. But the user inputs are only updated once per call to the app::Loop() method.

So, while you can have a while loop in Tier 1 that waits for a pointer press and then continues to the code after the while loop. In Tier 2, you will get a hung application.

This made me a little crazy when I converted my Tier 1 app to Tier 2 until I figured out what was happening.

But, once I reworked the code to use state machine like processing, the benefits of C++ are great. String handling alone makes the biggest difference (std::string, sprintf, etc.).
Cheers,
Ancient Lady
mrradd
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: CA, USA
Posted: 26th Dec 2015 23:53
I had a similar issue with get virtual button pressed. The button would be pressed and make a screen popup/disappear. The button could be held down and it would keep firing. I had to switch it to respond to a get released.
-mrradd-

Login to post a reply

Server time is: 2024-09-29 09:15:19
Your offset time is: 2024-09-29 09:15:19