Jump to content
  • Advertisement
Sign in to follow this  
Dasil

Custom Cursors

This topic is 3411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, So I started messing around with creating and loading custom cursors, but I am completely comfused about it. I know you have to do something with LoadCursor(), and I think it requires resource files and MAKEINTRESOURCE, but I'm not sure. By loading a custom cursor, I mean that I want it to replace the mouse arrow with a different image that I created. I searched around on google for a while, but nothing I found seemed to help me. Can you explain to me the steps and necessary functions required to create and load a custom cursor? I am using C++ and DirectX 9.0. Any help would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Are you creating a windowed application or a full screen one? If it is windowed then yes you want to create a cursor in the Resource View (View->Resource View)

Right click on your *.rc file and select Add Resource

Choose cursor, click new

Draw your cursor. In the Resource View you can name it to what ever you want

Now when you need it call LoadCursor()


If you are making a full screen app, you may not want to go this route. Instead you may want to create your own bitmap cursor (ie a texture with transparency around it) which you control inside the DirectX app like any other object. You'll then want to make sure you hide the windows's cursor out of view.

On my website you'll find a video which shows how to create a custom cursor here: http://www.marek-knows.com/downloadSection.php?Topic=GameDev&pg=6#GameDev112


Share this post


Link to post
Share on other sites
Thanks for your reply.

I am planning to make it into a fullscreen app. Right now I draw an image at the cursor location. This sort of works, but I have a problem with it. When the cursor is on the left half of the screen, the image is aligned properly with the cursor, but when it is on the right half of the screen, the image is shifted a little to the left, and the cursor is in the center of the image.

Also, I am using Visual C++ 2008 Express, and it doesn't have a resource editor that I know of.

I align the image to the mouse using:

void Mouse::alignToCursor()
{
POINT pt;

GetCursorPos(&pt);
ScreenToClient(hWnd, &pt);

mX = (float)pt.x;
mY = (float)pt.y;
}



then draw the image at (mX, mY). (It's a 2D game).

Share this post


Link to post
Share on other sites
Another problem with the image is that as the cursor moves down the screen, it moves lower on the image. When it is at the top, the cursor is at the top of the image, and everything is lined up properly. When the cursor is at the bottom of the screen, the cursor is at the bottom of the image.

Am I doing something wrong?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!