custom mouse cursor code
Posted: Mon Apr 22, 2013 8:15 pm
just recently, I made a custom displayable that checks the current mouse position, then places an image there based on a supplied list. combined with setting the renpy mouse cursor to an empty image, this can be used to change the mouse cursor whenever you feel like it.
to use the displayable either show it usingor if it's part of a screen, use
cursorlist should contain lists (or tuples, I don't really know the difference) of the format [image, area, offset], with area being set to "default" for the default cursor. area should be a rect of the same type as used for mouseareas. if this seems strange, it's because I'm a strange person.
an example would look like this:
something to note if you want to get rid of the renpy mouse cursor, I don't know if it was just me screwing up, but when I tried doing it myself, it made the cursor disappear in the menus as well. if this happens, just add custom_cursor to the screens for the menus as well.
since I might as well, I'm also leaving in the part of the file that I designed for making a flashlight follow the cursor. if you want to use that function, make a fullscreen image that is either black or in some other way dark and call it "no_flashlight.png" as well as an image that has height and width double that of your game's resolution with an empty circle in the center and call it "flashlight.png". once you've added those, you can set the keyword argument dark to true when using custom_cursor.
to use the displayable either show it using
Code: Select all
show expression custom_cursor(cursorlist)
Code: Select all
add custom_cursor(cursorlist)
an example would look like this:
Code: Select all
cursorlist = [["default_cursor.png", "default", (0, 0)],
["eye_cursor", (50, 50, 50, 50), (0, 0)]]
since I might as well, I'm also leaving in the part of the file that I designed for making a flashlight follow the cursor. if you want to use that function, make a fullscreen image that is either black or in some other way dark and call it "no_flashlight.png" as well as an image that has height and width double that of your game's resolution with an empty circle in the center and call it "flashlight.png". once you've added those, you can set the keyword argument dark to true when using custom_cursor.