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 / Best Way to Change Mouse Cursor?

Author
Message
Brian Lancaster
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 6th Sep 2020 17:39
I would really like to change the mouse cursor according to various commands and targeting in a tactical RPG. I know AppGameKit won't allow this by default, and I know it would be possible to program in a custom mouse cursor, but I was wondering if there was some kind of plugin DLL that I could use to make this easier.

If there's no DLL, does somebody have a code snippet for a custom mouse cursor just to save me some time? Thank you.
29 games
14
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 6th Sep 2020 18:33
I just hide the mouse cursor, replace it with a sprite and then position the sprite using GetRawMouseX() and GetRawMouseY().

You can have multiple sprite positioned liked this and show and hide them depending on the whatever "command" has been selected by the player.
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
blink0k
Moderator
7
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Conjured Entertainment
AGK Developer
15
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 7th Sep 2020 01:08 Edited at: 7th Sep 2020 01:50
Quote: "I just hide the mouse cursor, replace it with a sprite and then position the sprite using GetRawMouseX() and GetRawMouseY().
"


That is the simplest way, and the way I do it too in the main function that has the sync() call, and I use the SetRawMouseVisible(0) right after I create the custom sprite for the cursor before the main function in the initialization part of my program.

Quote: "You can have multiple sprite positioned liked this and show and hide them depending on the whatever "command" has been selected by the player."

I use animation frames for this rather than separate sprites, which is the same idea, just makes it easier for me to keep track by simply setting the frame and having only one sprite to position with the mouse X & Y .

(the example below is using a frame from a small atlas rather than just a single image to compact resources and/or allow for multiple cursor images, so you can ignore that part if you are using a single image)


(example below offsets the sprite for the finger on the hand (my sprite image) to be exact.. will depend on your sprite(s))
(this is at the top of that main function that has my sync() call)


The only thing to remember is that you will not know where that cursor is when displaying a message.

So, the user may have trouble hitting the okay button on the message dialog if you don't make it visible before the message and hide it again after.

Of course, they can just hit the enter key for that OK confirmation/continue, but I have experienced situations where the Ok may not have focus. (which will make hitting that OK a real hassle sometimes)

Showing the cursor again makes it solid, but you may have a little lag showing and hiding the cursor, but it should not be a problem in most cases since they need time to read the message and/or return to a ready state for play.

Again, just a heads up, not suggesting a 'best' way, just an option to take in consideration, or not, depending on your apps/users needs.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Brian Lancaster
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 7th Sep 2020 21:43
Thanks for all the replies. It's almost working with the custom sprite, but unfortunately the setRawMouseVisible command doesn't seem to work at all.

I tried Qugurun's plugin and it doesn't work, saying it may not be available for this platform (Windows 10).

I'm thinking it's impossible, but thanks for the help.
Brian Lancaster
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 8th Sep 2020 08:28
Alright, the SetRawMouseVisible command works now. I wish I could tell you what I did, but now it's working.
blink0k
Moderator
7
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 8th Sep 2020 08:42
When stuff like that doesn't work for my.
I try to write some code that just does that and nothing else
If it still doesn't work i make sure i have the latest version
If it still doesn't work i;
1) Uninstall AGK
2) Remove the C:\Users\your_id\AppData\Local\AGKApps folder
3) Reboot
4) Reinstall AGK
Brian Lancaster
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 8th Sep 2020 08:46 Edited at: 8th Sep 2020 08:53
Hahaha, I didn't do any of those things but then it started working, no more Windows mouse. Oh well, no more asking questions, pushing on.
Qugurun
Valued Member
5
Years of Service
User Offline
Joined: 8th Dec 2014
Location: Tyumen, Russia
Posted: 9th Sep 2020 14:03
https://forum.thegamecreators.com/thread/225433
Brian Lancaster, my solution may be unstable, i tried to make it universal. It seems that sometimes the cursor can return to its default state, because the application may lose focus or receive a signal to change the cursor from Windows, so that this does not happen, you need to call the command from time to time to set the cursor. I did the plugin more for interest, but at the moment I am not able to fix or write new plugins due to work.

Another not pleasant moment is that any plugin will not work if there is Cyrillic on the way to the application - this is the problem of the AGK.
Conjured Entertainment
AGK Developer
15
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 9th Sep 2020 16:08
I was using Windows 7 when coding my example above,

If we had a GetRawMouseVisible() as a boolean, then we could use it as a condition to see if it has been turned back on by Windows to turn it off again.

That way, we would not be setting it to off when not needed, which may, or may not, cause a bit of lag in performance.

I need to stat playing on Windows 10 more (have a laptop with it but seldom use it) , just to see its quirks firsthand to find better solutions.

Had enough trouble with 10 though to not want to use it. ( support for 7 ended January 14th of this year, so I need to take the plunge soon anyway )

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
jd_zoo
2
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 11th Sep 2020 20:26
Quote: "If we had a GetRawMouseVisible() as a boolean"


Yes that is a great idea for a future feature! As for Windows7 I don't think they rolled out clipboard history for it only Windows 10 (correct me if I'm wrong), the Win+V shortcut has become huge for me I'd recommend you check it out on your laptop sometime.
Brian Lancaster
6
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 17th Sep 2020 17:27
Yeah, I hate Windows 10 but now I'm stuck with it cause I threw out my old laptop.

Login to post a reply

Server time is: 2020-10-25 17:00:04
Your offset time is: 2020-10-25 17:00:04