[SOLVED] Help With Imagebuttons

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
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

[SOLVED] Help With Imagebuttons

#1 Post by Braydxne »

So I've decided to try and go for a more point n' click approach with my game, however the issue I'm having currently is this.

Code: Select all

label classexploration:
    $camera_move(0, 0, 0, 0, duration=0.35)
    $ change_cursor("1")
    hide window
    
    show screen interact1
    
    
screen interact1:
    if not checked_window:
        imagebutton:
            focus_mask True
            xpos 0 ypos 0
            idle "Interact1Window.png"
            hover "Interact1Window.png"
            action [SetVariable("checked_window", True), Hide("interact1"), Jump("window")] 
            hovered change_cursor("2")
            unhovered change_cursor("1")
                
            
label window:
    
    cothink "Why the hell is it {color=#fff200}boarded up{/color}?"
        
    jump classexploration
It seems to not wait for the window to be clicked and keeps jumping from the window label to classroomexploration. I'm not quite sure what's causing this.
Last edited by Braydxne on Wed Sep 20, 2017 8:25 pm, edited 1 time in total.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Help With Imagebuttons

#2 Post by Divona »

See Call Screen.

Code: Select all

    call screen interact1
Completed:
Image

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: Help With Imagebuttons

#3 Post by Braydxne »

Divona wrote: Tue Sep 19, 2017 1:24 am See Call Screen.

Code: Select all

    call screen interact1
Thank you again! It really helps ^^

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: Help With Imagebuttons

#4 Post by Braydxne »

While we're at it... how would I go about changing the mouse cursor when hovering over the imagebutton? I tried one method I found on the forums but it didn't work...

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Help With Imagebuttons

#5 Post by xela »

Code: Select all

hovered SetField(config, "mouse", {"default": [(cursor, xoff, yoff)]}) # Where cursor is a path to an image, xoff and yoff offsets to place it correctly.
unhovered SetField(config, "mouse", None)
Like what we're doing? Support us at:
Image

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: Help With Imagebuttons

#6 Post by Braydxne »

xela wrote: Tue Sep 19, 2017 1:12 pm

Code: Select all

hovered SetField(config, "mouse", {"default": [(cursor, xoff, yoff)]}) # Where cursor is a path to an image, xoff and yoff offsets to place it correctly.
unhovered SetField(config, "mouse", None)
Thank you so much! That's perfect! ^^ I have one final question concerning the mouse cursor, how would I go about changing it when the menu appears. I only care because if you pause while doing an investigation the cursor remains the big magnifying glass which is interesting to say the least. Thank you again for your help!

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Help With Imagebuttons

#7 Post by Divona »

Braydxne wrote: Tue Sep 19, 2017 7:03 pm how would I go about changing it when the menu appears. I only care because if you pause while doing an investigation the cursor remains the big magnifying glass which is interesting to say the least. Thank you again for your help!
screens.rpy

Code: Select all

screen game_menu(title, scroll=None):

    style_prefix "game_menu"

    on "show" action SetField(config, "mouse", None)
    
    . . .
Completed:
Image

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: Help With Imagebuttons

#8 Post by Braydxne »

Divona wrote: Tue Sep 19, 2017 11:00 pm
Braydxne wrote: Tue Sep 19, 2017 7:03 pm how would I go about changing it when the menu appears. I only care because if you pause while doing an investigation the cursor remains the big magnifying glass which is interesting to say the least. Thank you again for your help!
screens.rpy

Code: Select all

screen game_menu(title, scroll=None):

    style_prefix "game_menu"

    on "show" action SetField(config, "mouse", None)
    
    . . .
Thank you so much! You've been a big help! I'm grateful you took the time to tell me the code.

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: Help With Imagebuttons

#9 Post by Braydxne »

Braydxne wrote: Tue Sep 19, 2017 11:19 pm
Divona wrote: Tue Sep 19, 2017 11:00 pm
Braydxne wrote: Tue Sep 19, 2017 7:03 pm how would I go about changing it when the menu appears. I only care because if you pause while doing an investigation the cursor remains the big magnifying glass which is interesting to say the least. Thank you again for your help!
screens.rpy

Code: Select all

screen game_menu(title, scroll=None):

    style_prefix "game_menu"

    on "show" action SetField(config, "mouse", None)
    
    . . .
Thank you so much! You've been a big help! I'm grateful you took the time to tell me the code.
Although the code doesn't appear to be working when put in screens.rpy. Is there a specific place I should put it? I put it near the top and it didn't work. It doesn't crash or anything it just doesn't change the mouse.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Help With Imagebuttons

#10 Post by Imperf3kt »

Code: Select all

screen game_menu(title, scroll=None):

    style_prefix "game_menu"
These lines already exist in screens.rpy
If you use Editra, hold CTRL and press F
Start typing one of the lines, it will find it.

Now paste the rest below that.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: Help With Imagebuttons

#11 Post by Braydxne »

Imperf3kt wrote: Wed Sep 20, 2017 12:07 am

Code: Select all

screen game_menu(title, scroll=None):

    style_prefix "game_menu"
These lines already exist in screens.rpy
If you use Editra, hold CTRL and press F
Start typing one of the lines, it will find it.

Now paste the rest below that.
Ahhh.. Okay! Thank you for clarifying!

Post Reply

Who is online

Users browsing this forum: No registered users