Jump to content

Custom cursor broken?


Duion

Recommended Posts

Inside the default template there is code to define a custom default cursor that you can modify.

https://github.com/GarageGames/Torque3D/blob/c83efa59e0a11fc15c68afaf106807643191ac6f/Templates/Full/game/core/scripts/gui/cursors.cs#L34-L38

I tried adding a custom graphic for the cursor, but I noticed that the custom cursor is never loaded, the game will always use the default windows cursor.


So how can I make it work? Or is it never used or cannot work? If so can I delete it?

Link to comment
Share on other sites

  • 1 year later...

I recall in the past I had to add

overrideplatformcursor = true in guicanvas.cpp and h I will see if I can find the code


end of guiCanvas.h add this


protected:

bool mOverridePlatformCursor;

public:

void overridePlatformCursor( bool state = true )

{

mOverridePlatformCursor = state;

}


end of guiCanvas.cpp add this


ConsoleMethod( GuiCanvas, overridePlatformCursor, void, 2, 3, "(value=true)" )

{

bool value = true;

if( argc > 2 )

value = dAtob( argv[ 2 ] );

object->overridePlatformCursor( value );

}


in game script files main.cs at the end of createCanvas add this


if (isObject(Canvas))

Canvas.overridePlatformCursor(true);

return true;


in script cursors.cs add the new cursor

new GuiCursor(CrossHairCursor)

{

hotSpot = "8 8";

renderOffset = "0 0";

bitmapName = "core/art/gui/images/crosshair_white";

};


then any time in game script you want a different cursor


function MEvent::onMouseEnter(%this,%b,%point,%m)

{

Canvas.setCursor("CrosshairCursor");

}


Hope this helps...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...