Changing cursor by clicking on a button?

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
sapiboonggames
Veteran
Posts: 299
Joined: Thu Jan 05, 2012 8:53 am
Completed: I Love You, Brother [BxB]
Contact:

Changing cursor by clicking on a button?

#1 Post by sapiboonggames »

Hello, I'm trying to make a screen in which if I select a button, the cursor changes.

Below is the code that I'm using.

Code: Select all

## HANDS BUTTON ## 
    imagebutton:
        xpos 921
        ypos 87
        idle "foreplay/handbutton_idle.png"
        hover "foreplay/handbutton_hover.png"
        action SetScreenVariable('mousepointer', 1)
    ## MOUTH BUTTON ##
    imagebutton:
        xpos 1026
        ypos 87
        idle "foreplay/mouthbutton_idle.png"
        hover "foreplay/mouthbutton_hover.png"
        action SetScreenVariable('mousepointer', 2)
    ## CLOTHES BUTTON ##
    imagebutton:
        xpos 1131
        ypos 87
        idle "foreplay/clothesbutton_idle.png"
        hover "foreplay/clothesbutton_hover.png"
        action SetScreenVariable('mousepointer', 3)

    if mousepointer == 1:
        $ config.mouse = {"default" :[("foreplay/cursorhand.png", 0, 0)]}
    elif mousepointer == 2:
        $ config.mouse = {"default" :[("foreplay/cursormouth.png", 0, 0)]}
    elif mousepointer == 3:
        $ config.mouse = {"default" :[("foreplay/cursorclothes.png", 0, 0)]}
    else:
        $ config.mouse = {"default" :[("foreplay/cursordefault.png", 0, 0)]}
The thing is, the cursor flickers a bit to the desired cursor, but quickly changes to the default cursor.

Thanks for any help!
Last edited by sapiboonggames on Sun Nov 15, 2015 7:21 pm, edited 1 time in total.
Visit my website: http://www.sapiboong.com

User avatar
ringonoki-ua
Newbie
Posts: 15
Joined: Thu Mar 19, 2015 11:48 am
Projects: Rozumnyk/Sofia
Deviantart: ringonoki
Skype: ringonoki-ua
Location: Kyiv, Ukraine
Contact:

Re: Changing cursor by clicking on a button?

#2 Post by ringonoki-ua »

Maybe you should look into renpy source files to find out in what circumstances cursor is being redrawn on screen?

User avatar
sapiboonggames
Veteran
Posts: 299
Joined: Thu Jan 05, 2012 8:53 am
Completed: I Love You, Brother [BxB]
Contact:

Re: Changing cursor by clicking on a button?

#3 Post by sapiboonggames »

ringonoki-ua wrote:Maybe you should look into renpy source files to find out in what circumstances cursor is being redrawn on screen?
I can't really code outside of renpy, so looking at the source file would be out of my abilty :oops:

Really hope that someone could help me with this.
Thank you!
Visit my website: http://www.sapiboong.com

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Changing cursor by clicking on a button?

#4 Post by philat »

In general, config variables are not meant to be changed outside of init runtime. That said, if I were trying to do this, I would probably test to see if config.mouse will accept a ConditionSwitch image. If not, I would have to look into the common files to see how it's set up. *shrug*

Post Reply

Who is online

Users browsing this forum: No registered users