Game Maker's Garage Forum

Game Creation => GameMaker => Topic started by: Zoo on February 13, 2011, 12:08:04 PM

Title: Custom cursors
Post by: Zoo on February 13, 2011, 12:08:04 PM
I read somewhere GM can have custom cursors for games. How does this work? I want to have a gun-scope crosshairs for a game I'm making.
Title: Re: Custom cursors
Post by: Connors on February 13, 2011, 11:51:50 PM
I know there are some default cursors, like direction arrows or a hand etc., but I don't know that there's a way to customize them.
Title: Re: Custom cursors
Post by: Silverwind on February 14, 2011, 02:07:45 AM
It involves replacing the resource files I think. I can't remember how though, as I've never done it before.
Title: Re: Custom cursors
Post by: GMG Mike on February 14, 2011, 12:20:59 PM
You can use Rezilla to customize the cursors. It's an old PowerPC program but it will run on new Macs with Rosetta. OS X will automatically download Rosetta if you don't already have it installed.

http://sourceforge.net/projects/rezilla/

Check the GameMaker Read Me file for more information on how to install the custom cursor.
Title: Re: Custom cursors
Post by: Zoo on February 14, 2011, 03:07:25 PM
thanks, anyone know how to put them in a game?
Title: Re: Custom cursors
Post by: Silverwind on February 14, 2011, 05:00:23 PM
Here's the instructions from More Notes (packaged with Mac GameMaker):

----- CREATING CUSTOM CURSORS -----
You can create up to 10 new cursors to use in your game. Use ResEdit or other resource editor to create "crsr" resources. Put the resources in your project file. Don't put them in the GameMaker application. Make sure the game is not open in GameMaker while you are adding cursors or they will not be displayed. In ResEdit, use "Get Resource Info" in the "Resource" menu to name and renumber the cursors. The new cursors must have a name for them to show up in GameMaker. The resource ID numbers must start at 1010 and continue with 1011, 1012, and so on for as many cursors as you create.
Title: Re: Custom cursors
Post by: Zoo on February 14, 2011, 05:46:19 PM
Ok, you got me. What the heck is ResEdit? lol
Title: Re: Custom cursors
Post by: Gan on February 14, 2011, 06:01:24 PM
A resource fork editing application.
Title: Re: Custom cursors
Post by: Al Staffieri on February 14, 2011, 07:04:31 PM
Quote
Ok, you got me. What the heck is ResEdit? lol

As Mike said you can use Rezilla in place of ResEdit (ResEdit does not work on new Macs). Open your game in Rezilla. In the Resources menu select New Resource. For resource type put crsr. For ID put 1010. Then enter a name for the cursor. Then press Create and you'll get a window to draw a new cursor. Then save and that's it. It will be available in your game.
Title: Re: Custom cursors
Post by: Zoo on February 14, 2011, 08:41:03 PM
Sweet!
EDIT: That works. OMG This will be so useful. How do you change it's size?
Title: Re: Custom cursors
Post by: GMG Mike on February 15, 2011, 05:35:30 PM
Quote
Sweet!
EDIT: That works. OMG This will be so useful. How do you change it's size?

You can't. "crsr" style cursors can only be 16x16. You can draw it smaller than that but not bigger.
Title: Re: Custom cursors
Post by: Zoo on February 16, 2011, 03:19:02 PM
Oh well. doesn't really matter anyway. the normal size is big enough.  :P
Title: Re: Custom cursors
Post by: Al Staffieri on February 17, 2011, 07:03:44 AM
Depending on what you want, there are two built in cross hair cursors. You can try one of these.

SETCURSOR 2
SETCURSOR 3

There are also some cursors I made at:
http://alstaffieri.com/gmaddons.html#cursors

You can open that file with Rezilla and add them to your game. Thyere is a crosshairs cursor in there.
Title: Re: Custom cursors
Post by: Zoo on February 17, 2011, 03:19:05 PM
those are pretty good.
Title: Re: Custom cursors
Post by: GMG Kurt on March 06, 2011, 08:53:19 PM
This block of code also works for changing the arrows, and is much simpler, and doesn't conform to arrow size constraints.
It can also act as a sprite for use in Avoider games

(make sure to check the loop script option)
SETCURSOR -1
REPEAT 100
  SPRITE 1 MouseHorz MouseVert  file.gif
END REPEAT

There are only two things wrong with it.

changing the repeat variable to a lower value will cause choppier movement, because of the loop script code, and the number (even as small as 100) will cause a delay with other commands being executed, since the repeat command has to run through

The setcurser command, using negative numbers doesn't seem to work on my computer, maybe on yours. I don't know
Title: Re: Custom cursors
Post by: GMG Mike on March 07, 2011, 12:22:16 AM
A better way might be to do it with a timer.

I don't think there's an ON MOUSEMOVE event, but that would be the best way to do it.
Title: Re: Custom cursors
Post by: Al Staffieri on March 07, 2011, 10:02:21 AM
You shouldn't need a REPEAT loop. Just check the Loop Script option. That will keep running the script.

SETCURSOR -1 makes the cursor invisible. Works here. However it becomes visible when you are above the window, so you can select menus and when you are in the button area, so you can click a button. Perhaps I should change it so it's only visible when you are at the top in the menu bar.
Title: Re: Custom cursors
Post by: GMG Kurt on March 08, 2011, 03:46:44 PM
Quote
A better way might be to do it with a timer.

I tried doing it without a timer, and it works, but the new cursor doesn't follow it as exactly, and smoothly as the repeat command does. The repeat method makes the image look more like a custom cursor, and less like some random SPRITE following your invisible cursor
Title: Re: Custom cursors
Post by: Zoo on March 08, 2011, 04:26:17 PM
Uhh, this is great, but I can't click anything with new mouse, and none of the background shows up. Plus the setcursor -1 thing doesn't work here either.
Title: Re: Custom cursors
Post by: GMG Kurt on March 08, 2011, 04:34:15 PM
Quote
Uhh, this is great, but I can't click anything with new mouse, and none of the background shows up. Plus the setcursor -1 thing doesn't work here either.
The background might not be showing up if it's a sprite also. I don't know if thats how you have it set up. I tried that once to re-create an NES style game, but it was to complicated for me back then.
Maybe you should try changing the sprite number to something else, you know your not using.
Title: Re: Custom cursors
Post by: Zoo on May 05, 2011, 03:55:10 PM
How do you get a custom cursor to work with SETCURSOR?