Mouse cursor - how do you do this thing?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Mouse cursor - how do you do this thing?

Post by Foxley »

I used the example script in the mouse section of plotdict.xml, put it in the new game autorun script, and it just puts the walkabout mouse cursor I drew in the top left corner and nothing happens. I think I should probably get past this somewhat crucial phase of "making a game with mouse controls" before I move onto stuff like clicking on things.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

So, first of all, check that the script is actually running. If you press F10 twice you'll enter the script debugger, and should see the displaymouse script listed. Also, check there isn't any other script listed above displaymouse (with the exception of an on-keypress script which doesn't contain any wait commands). If there is another script above, then it's in control, everything below the top script is paused. Press F10 again to leave the debugger.

The only other thing that could go wrong is that your NPC doesn't have ID 0. That's what the script assumes.

I'll update that example to use a slice instead of an NPC; using an NPC as mouse cursor is a bad idea as other NPCs can't move to the tile the NPC is at, and it won't be drawn above everything else.
Last edited by TMC on Mon Jun 08, 2015 12:12 pm, edited 1 time in total.
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Thank you TMC, I just tried that and it worked like a charm.
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

By the way, I would suggest also adding

Code: Select all

slice to front (mousecursor)
to the plotdict.xml example for making the mouse cursor, in the same while loop as "put slice (mousecursor)". I tried it and it works great, mouse cursor always stays on top of everything.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Ah, good point. But that still results in the cursor being underneath textboxes. So instead I added

Code: Select all

  move slice above (cursor, lookup slice (sl:textbox layer))
Note that some things (menus and strings) still aren't drawn using slices, they're drawn above the slice tree instead, so it's not possible to display the cursor above them.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

That's one of the reasons I realized that making the text boxes text slices was a better idea. It's easier to manage the parenting of everything that way, because they are slices you've created rather than ones in there by default.
My pronouns are they/them
Ps. I love my wife
Post Reply