Gw Temp

Menu

Tutorial - 'Custom Cursor' by DarkPriest

An item about RPGMaker 2000 posted on

Blurb

Learn how to create a custom cursor in your Gamemaker games

Body

So, you want a custom cursor to your game?

... what do I mean with a custom cursor?



The very normal mouse can be visible or hidden over your


gamemaker game window, depending on wether show_cursor

is set to true (visible) or false (hidden). The mouse, however,

still exists. The cursor is just hidden.



Ok, so the normal arrow cursor is a little too generic... doesn't

quite suit the feel of your game? Let's change it then!



The very first think you'll need is a sprite for your new cursor.

It can be animated, it can be big, it can be small, it can be

pretty much anything (Gamemaker is so damn flexible).



If you don't have one already, feel free to use this:

by ME



Now that we have the sprite in order, lets import it to gamemaker.

I presume you know how to do this already, but if not lets go over

it once more. First right-click on the "Sprites" tree. Choose Add Sprite.

Name the new sprite to something like sprCursor or Cursor, whatever

you prefer. Next choose Load Sprite. Find your sprite and select it.


Now we only need to define the origins. Click on the Advanced page,

and set the X and the Y origin (x = sprite width / 2 and y = sprite width / 2).



Next we create a new object. Name is objCursor, objMouse or something similar.

Set the depth of this event to -1000 or so, that it'll appear over other graphics and won't go under them.

We'll only need to simple snipets of script for it. First one goes into the Create event.

Here we'll turn the default cursor invisible with



{

show_cursor = false;


}



Thats that, we've gotten rid of the default cursor. Now we only need to have

the new object move as the mouse does. The best way to achieve this is

the following piece of script which goes into the step event of our cursor object.



{

x = mouse.x;

y = mouse.y;


}



What we have here, is an object - which once placed into a room - eliminates the

default windows cursor and changes its x and y to match the current x and y of the mouse

durin each step. Normally this is around 30 steps / second so basically the cursor updates

its place 30 times / second. Quite nifty, eh?



That wasn't so hard, was it ? Now just put this object into the rooms

where you want to use your brand new cursor!