Switching between 2 custom mouse cursors (solved)

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
User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

Switching between 2 custom mouse cursors (solved)

#1 Post by Smaymay » Thu Mar 09, 2017 9:11 am

Hi there!

I'm currently looking at the possibilities of coding a Point & Click game in Ren'py.
I want the player to click on a character sprite to initiate a conversation.

So I put an imagebutton inside a screen.

Code: Select all

screen waldo_small_L:
    imagebutton:
            idle "images/waldo_small_L.png"
            xanchor 0.5 yanchor 0.5
            xpos 1123 ypos 580 focus_mask None
            action Jump("waldo_dialoog")
And called that screen in my script file.

Code: Select all

label waldo_dialoog:
    hide screen waldo_small_L
    show waldo neutral at center
    wr "Hey."
It works fine. But I want to switch my custom cursor to another cursor with an white outline when the player hovers on an imagebutton with a character sprite.
This is the code I used to create a custom mouse cursor:

Code: Select all

init 1 python:
    def change_cursor(type="default"):
        persistent.mouse = type
        if type == "default":
            setattr(config, "mouse", {"default": [("images/mouse_pointer.png", 8.0, 0.0)]})
        elif type == "hover":
            setattr(config, "mouse", {"default": [("images/mouse_pointer_hover.png", 8.0, 0.0)]})

    if not hasattr(persistent, "mouse"):
        change_cursor()
    else:
        change_cursor(persistent.mouse)
But I don't know how to change the 'hover' and 'unhovered' behaviour of my imagebutton to get the right mouse cursor.
I guess it has to do something with a variable. But maybe someone here has an idea how to go about this. :) :?:
Last edited by Smaymay on Sat Mar 11, 2017 4:56 pm, edited 2 times in total.

User avatar
Saltome
Veteran
Posts: 237
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: Question about switching between 2 custom mouse cursors

#2 Post by Saltome » Thu Mar 09, 2017 2:45 pm

Hmm, maybe this will help. viewtopic.php?f=8&t=37403&hilit=mouse
Deviant Art: Image

User avatar
Smaymay
Regular
Posts: 70
Joined: Fri Jul 01, 2016 11:35 am
Completed: Vicboys demo
Tumblr: esmmeh
Deviantart: Smaymay
Location: The Netherlands
Contact:

Re: Question about switching between 2 custom mouse cursors

#3 Post by Smaymay » Sat Mar 11, 2017 12:52 pm

Thank you. That thread was very helpful! :)

Post Reply

Who is online

Users browsing this forum: enaielei