Transparent area changing cursor

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Aeezakmi
Newbie
Posts: 2
Joined: Sat Feb 25, 2017 8:21 pm
Contact:

Transparent area changing cursor

#1 Post by Aeezakmi » Sat Feb 25, 2017 8:27 pm

Soo as the title says, I need help making a transparent field on the screen, which changes the mouse cursor on hover. I'm new to RenPy and this is a real headbanger for me :D

I managed to find this on the internet:

Code: Select all

init 1 python:
    def change_cursor(type="default"):
        persistent.mouse = type
        if type == "default":
            setattr(config, "mouse", None)
        elif type == "1":
            setattr(config, "mouse", {"default": [("images/1.png", 31, 28)]})
        elif type == "2":
            setattr(config, "mouse", {"default": [("images/2.png", 0, 0)]})
           
    if not hasattr(persistent, "mouse"):
        change_cursor()
    else:
        change_cursor(persistent.mouse)
   
# The game starts here.
label start:
    $ change_cursor()
    "Normal Cursor"
   
    $ change_cursor("1")
    "Cursor 1"
   
    $ change_cursor("2")
    "Cursor 2"
   
    return

and then tried to "tweak" it for my purpose:

Code: Select all

screen testing():
    
    imagemap:
            ground "border_female"
       
            hotspot (0, 0, 247, 270) hovered Function(change_cursor,"1")
    
   

init 1 python:
        def change_cursor(type="default"):
            persistent.mouse = type
            if type == "default":
                setattr(config, "mouse", None)
            elif type == "1":
                 setattr(config, "mouse", {"default": [("magnifier_cursor.png", 0, 0)]})
           
        if not hasattr(persistent, "mouse"):
            change_cursor()
        else:
            change_cursor(persistent.mouse)        
I'm just trying to test it with random image, before imagemap, tried making it with button or imagebutton still didn't work..
Can you guys help me out :/ ?
Thanks in advance !

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Transparent area changing cursor

#2 Post by korova » Sun Feb 26, 2017 6:24 am


User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Transparent area changing cursor

#3 Post by Ocelot » Sun Feb 26, 2017 6:32 am

Do you need to change cursor only when mouse is above certain area? How about using mouse property of a button then?
< < insert Rick Cook quote here > >

Aeezakmi
Newbie
Posts: 2
Joined: Sat Feb 25, 2017 8:21 pm
Contact:

Re: Transparent area changing cursor

#4 Post by Aeezakmi » Sun Feb 26, 2017 9:59 am

Ocelot wrote:Do you need to change cursor only when mouse is above certain area? How about using mouse property of a button then?
How does that work : ? Can't seem to understand from the documentation.

Post Reply

Who is online

Users browsing this forum: Google [Bot]