Page 1 of 1

Changing cursor by clicking on a button?

Posted: Sun Nov 15, 2015 12:13 pm
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!

Re: Changing cursor by clicking on a button?

Posted: Sun Nov 15, 2015 12:45 pm
by ringonoki-ua
Maybe you should look into renpy source files to find out in what circumstances cursor is being redrawn on screen?

Re: Changing cursor by clicking on a button?

Posted: Sun Nov 15, 2015 7:21 pm
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!

Re: Changing cursor by clicking on a button?

Posted: Sun Nov 15, 2015 8:54 pm
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*