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 / How to clear the mouse button after use?

Author
Message
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 25th Jul 2017 21:56 Edited at: 25th Jul 2017 22:10
Here's my code...

if GetPointerPressed() = 1
(do line of code here)
endif

(New line of code here)

It checks to see if the left mouse button is being pressed.
But how can I clear it after it's done? I need to go to my next line of code with a clear mouse, but it doesn't, and it messes up my game.

Is there any way to clear the mouse so it turns off or something? I only press it once and it doesn't clear afterwards. I need it to clear immediately after it is pressed.
.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 25th Jul 2017 22:10
maybe try something like this



but I would think you can make better use of the GetPointer* functions, without knowing exactly your doing its hard to judge but maybe a better structure to your code will avoid this problem?
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 25th Jul 2017 22:14 Edited at: 25th Jul 2017 22:38
I would like to 'clear the mouse cache' , I think they say.

maybe my code is faulty too, I'll check that out.

But i will definitely try your line of code..., thanks.

So you think I should put a sync() in there ? That's interesting, I might try that.
.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 25th Jul 2017 22:34
there is no mouse buffer its an event driven system, GetPointerPressed() should only return 1 or true the moment the mouse is clicked and will only be true for that single frame, GetPointerState() will return true all the time the button is down and GetPointerReleased() returns true the moment the mouse is released, in the case of Pressed and Released the true return should only register for a single frame and reset automatically on the next frame.
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 25th Jul 2017 22:40 Edited at: 25th Jul 2017 22:41
Maybe I should put a 'sync() in there.... maybe that's my problem.
.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 26th Jul 2017 16:59
No you can (and you must !) only handle that with a variable flag like already shown

But if you have multiple conditions for a mouse click, you have certainly something different for each condition (position? Game state?)
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Jul 2017 12:57
May try executing the mouse not pressed conditions before the mouse pressed ones?

For example:

if GetPointerPressed() = 0
//do this
else
//do that
endif
Signature removed by mod because it's larger than 600x120... please resize and try again.

Login to post a reply

Server time is: 2024-09-30 05:32:52
Your offset time is: 2024-09-30 05:32:52