Hi everyone, a really noob question here. I've spent the last few days trying to figure this out before asking anyone here. Basically, I'm having trouble setting up an image button. The good news is that I finally got it to work with no errors, but the idle and hover states are not being displayed. It seems like a lot of people go about setting this up in different ways. But here's the code that finally got me closer. Please, I am very open to suggestions, pointing out stupid mistakes in my script, or being pointed to some great learning tools. I'm an artist, use to criticism. Thanks. Also, is there a way to post the code with the indents??
label chapter_1:
scene cart_outside with dissolve
##image button
screen cart_idle():
add "cart_outside"
modal True
imagebutton:
focus_mask True
xanchor 0.5
yanchor 0.5
xpos 0.5
ypos 0.5
idle "cart_inside_idle"
hover "cart_inside_hover"
action Jump ("inside_cart")
show fallville with dissolve
$ renpy.pause(3.0)
hide fallville with dissolve
pause
jump inside_cart
return
ImageButton not showing idle or hover
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.
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.
-
- Newbie
- Posts: 8
- Joined: Mon Nov 08, 2021 9:32 pm
- Projects: Hussies of Pleasureville
- IRC Nick: Scarecrow-76
- itch: Scarecrow-76
- Contact:
Re: ImageButton not showing idle or hover
In your code sample you've declared (created) a screen with imagebutton, but didn't show this screen.
Try it like
Code: Select all
##image button screen
screen cart_idle():
add "cart_outside"
modal True
imagebutton:
focus_mask True
xanchor 0.5
yanchor 0.5
xpos 0.5
ypos 0.5
idle "cart_inside_idle"
hover "cart_inside_hover"
action Jump ("inside_cart")
label start:
"... ..."
"Since there is no other lines in this block of code, game will execute next block (label 'chapter_1')"
label chapter_1:
scene cart_outside with dissolve
"..."
show fallville with dissolve
$ renpy.pause(3.0)
hide fallville with dissolve
$ renpy.pause()
call screen cart_idle
"Player shouldn't get here, 'cause button in screen will transition him/her to another label"
label inside_cart:
"done"
return # should return player back to main menu
https://www.renpy.org/doc/html/screen_actions.html
To post the code with indentation you need to put it between 'code' tags. At the top of the post form click the '</>' button to get this tags in your post.
-
- Newbie
- Posts: 8
- Joined: Mon Nov 08, 2021 9:32 pm
- Projects: Hussies of Pleasureville
- IRC Nick: Scarecrow-76
- itch: Scarecrow-76
- Contact:
Re: ImageButton not showing idle or hover
Thank you so much. It mostly worked. But the other problems were my mistake. I didnt have the image buttons artwork as "define", I had them as "image". Also, the main reason it seemed to give me trouble was that I had the Fallville text appear on the side for 3 seconds, but didnt crop it out to size. Instead I had assumed that since it was a png, anything behind the transparent area would be clickable, it's obviously not.
The only problem now, is that the cart doesnt show idle or its not clickable until the Fallville title dissolves away after the 3 seconds. While the Fallville is being displayed, idle or hover wont show. Once it's gone, it works. I was thinking maybe I could add it underneath the "call screen cart_idle" and put show in front command on it, which I tried doing but failed? Thanks again.
##image button
screen cart_idle():
add "cart_outside"
modal True
imagebutton:
focus_mask True
xanchor 0.5
yanchor 0.5
xpos 0.5
ypos 0.5
idle "cart_idle"
hover "cart_hover"
action Jump ("inside_cart")
label chapter_1:
scene cart_outside with dissolve
show fallville with dissolve:
xpos 0.0
ypos 0.0
xanchor 0.0
yanchor 0.0
$ renpy.pause(3.0)
hide fallville with dissolve
call screen cart_idle
label inside_cart:
"done"
return
The only problem now, is that the cart doesnt show idle or its not clickable until the Fallville title dissolves away after the 3 seconds. While the Fallville is being displayed, idle or hover wont show. Once it's gone, it works. I was thinking maybe I could add it underneath the "call screen cart_idle" and put show in front command on it, which I tried doing but failed? Thanks again.
##image button
screen cart_idle():
add "cart_outside"
modal True
imagebutton:
focus_mask True
xanchor 0.5
yanchor 0.5
xpos 0.5
ypos 0.5
idle "cart_idle"
hover "cart_hover"
action Jump ("inside_cart")
label chapter_1:
scene cart_outside with dissolve
show fallville with dissolve:
xpos 0.0
ypos 0.0
xanchor 0.0
yanchor 0.0
$ renpy.pause(3.0)
hide fallville with dissolve
call screen cart_idle
label inside_cart:
"done"
return
Re: ImageButton not showing idle or hover
Well, actually, you can't click on cart 'cause you didn't show it yet.scarecorw-76 wrote: ↑Tue Nov 23, 2021 3:41 pm ...The only problem now, is that the cart doesnt show idle or its not clickable until the Fallville title dissolves away after the 3 seconds. ...
In your 'cart_idle' screen you add "cart_outside" image. And in your label 'chapter_1' you show this image. So, while 'fallville' is shown it's just a bg image with cart, not the screen with button.
To test it try
Code: Select all
label chapter_1:
#scene cart_outside with dissolve
"..."
show fallville with dissolve
$ renpy.pause(3.0)
hide fallville with dissolve
$ renpy.pause()
call screen cart_idle
"Player shouldn't get here, 'cause button in screen will transition him/her to another label"
BG images and sprites are shown on a 'master' layer while screens are shown on 'screens' layer that is shown over the 'master' layer.
https://www.renpy.org/doc/html/config.h ... fig.layers
-
- Newbie
- Posts: 8
- Joined: Mon Nov 08, 2021 9:32 pm
- Projects: Hussies of Pleasureville
- IRC Nick: Scarecrow-76
- itch: Scarecrow-76
- Contact:
Re: ImageButton not showing idle or hover
Yup, that seemed to be what was happening. So I decided to add an extra image of the area with fallville appearing over that one, then dissolving into the close-up of the cart with the image button. Actually works much better as an intro to the area. Thanks so much for taking the time. I've been reading through the documentation, but a lot of it still goes over my head as to actually implement it. Hey look at that, I actually posted the code correctly this time.
Code: Select all
##create image button
screen cart_idle():
add "cart_outside"
modal True
imagebutton:
focus_mask True
xanchor 0.5
yanchor 0.5
xpos 0.5
ypos 0.5
idle "cart_idle"
hover "cart_hover"
action Jump ("inside_cart")
label chapter_1:
scene fallville_outside with dissolve
show fallville with dissolve:
$ renpy.pause(3.0)
hide fallville with dissolve
pause
#call the image button that was create
call screen cart_idle
Who is online
Users browsing this forum: Google [Bot]