[SOLVED] Imagebutton Problem

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
XemiTicTac
Newbie
Posts: 12
Joined: Mon Oct 28, 2019 12:40 pm
Contact:

[SOLVED] Imagebutton Problem

#1 Post by XemiTicTac » Mon Oct 28, 2019 12:58 pm

Hi ! Im new in Renpy and im learning how to code. My problem is: i have an Imagebutton with screen, it shows in the game but when i press the mouse wheel to hide the chat text, the imagebutton hides too. I dont know what can i do to dont hide my imagebuttons. I saw something about layer config but i dont know how to put it. Sorry for my bad english.

I followed a video to do that imagebutton, here is my code from that:

In my rpy file i have this:
screen hint_screen(hints=[]):
for hint in hints:
if hint.use_outline():
imagebutton idle hint.outline:
focus_mask True
action NullAction()
hovered Function(hint.call_func)
xalign hint.x
yalign hint.y
imagebutton idle hint.img:
focus_mask True
action NullAction()
hovered Notify(hint.hint_text)
xalign hint.x
yalign hint.y
In my other rpy file i have this:
init python:
class Hint:
def __init__(self, img, outline, x, y, var_check, func, hint_text):
self.img = img
self.outline = outline
self.x = x
self.y = y
self.var_check = var_check
self.func = func
self.hint_text = hint_text

def call_func(self):
self.func()

def use_outline(self):
return self.var_check()

def seen_emp():
store.emp_seen = True

def has_seen_emp():
return not emp_seen

emp_hint = Hint("tellia.png", "tellia_idle.png", 0.5, 1.0, has_seen_emp, seen_emp, "Hey, how are you?")

default emp_seen = False
Last edited by XemiTicTac on Wed Oct 30, 2019 3:06 pm, edited 3 times in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 2342
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Imagebutton Problem

#2 Post by Alex » Mon Oct 28, 2019 3:19 pm

XemiTicTac wrote:
Mon Oct 28, 2019 12:58 pm
... I dont know what can i do to dont hide my imagebuttons. I saw something about layer config but i dont know how to put it. ...
Yes, in Ren'Py 'things' are shown on layers (similar to photoshop). So, when you press mousewheel or 'H', everything on some layers hides.
You can add another layer and show screens you don't need to hide on it. Try

Code: Select all

init python:
    config.layers.insert(3, "my_layer")
https://www.renpy.org/doc/html/config.h ... fig.layers

By default there are 4 layers in a list (with indexes 0, 1, 2 and 3), so if new layer will be inserted with index 3, it will be placed between 'screens' and 'overlay' layers.

Then set for your screen the layer to show it on, like

Code: Select all

screen my_scr():
    layer "my_layer"
    
    text "Hello!" align(0.95, 0.1)
https://www.renpy.org/doc/html/screens. ... -statement

User avatar
XemiTicTac
Newbie
Posts: 12
Joined: Mon Oct 28, 2019 12:40 pm
Contact:

Re: Imagebutton Problem

#3 Post by XemiTicTac » Tue Oct 29, 2019 4:45 am

Alex wrote:
Mon Oct 28, 2019 3:19 pm
XemiTicTac wrote:
Mon Oct 28, 2019 12:58 pm
... I dont know what can i do to dont hide my imagebuttons. I saw something about layer config but i dont know how to put it. ...
Yes, in Ren'Py 'things' are shown on layers (similar to photoshop). So, when you press mousewheel or 'H', everything on some layers hides.
You can add another layer and show screens you don't need to hide on it. Try

Code: Select all

init python:
    config.layers.insert(3, "my_layer")
https://www.renpy.org/doc/html/config.h ... fig.layers

By default there are 4 layers in a list (with indexes 0, 1, 2 and 3), so if new layer will be inserted with index 3, it will be placed between 'screens' and 'overlay' layers.

Then set for your screen the layer to show it on, like

Code: Select all

screen my_scr():
    layer "my_layer"
    
    text "Hello!" align(0.95, 0.1)
https://www.renpy.org/doc/html/screens. ... -statement
Yeah it works ! Thank you very much ! :D

User avatar
XemiTicTac
Newbie
Posts: 12
Joined: Mon Oct 28, 2019 12:40 pm
Contact:

Re: Imagebutton Problem

#4 Post by XemiTicTac » Wed Oct 30, 2019 5:50 am

Sorry for re open the problem, but i have one more question about that. When i jump to another scene, the imagebutton doesnt disappear. I mean, when i use for example silvie at left and i jump to another scene, it disappear at same time as the background/scene. How can i do to config my layer or imagebutton to disappear at the same time as the background/scene, i searched on the documentation but i didnt find it. I tried to use the hide function but it doesnt disappear at the same time as the background/scene. Im really newbie sorry :?

User avatar
Alex
Lemma-Class Veteran
Posts: 2342
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Imagebutton Problem

#5 Post by Alex » Wed Oct 30, 2019 2:08 pm

XemiTicTac wrote:
Wed Oct 30, 2019 5:50 am
... I tried to use the hide function but it doesnt disappear at the same time as the background/scene. ...
It disappears when you hide it, so try to hide it right before showing new scene.

Screens are made to show some gui elements for players, so they don't disappear with new scene.

User avatar
XemiTicTac
Newbie
Posts: 12
Joined: Mon Oct 28, 2019 12:40 pm
Contact:

Re: Imagebutton Problem

#6 Post by XemiTicTac » Wed Oct 30, 2019 3:06 pm

Alex wrote:
Wed Oct 30, 2019 2:08 pm
XemiTicTac wrote:
Wed Oct 30, 2019 5:50 am
... I tried to use the hide function but it doesnt disappear at the same time as the background/scene. ...
It disappears when you hide it, so try to hide it right before showing new scene.

Screens are made to show some gui elements for players, so they don't disappear with new scene.
Oh i see, yeah it works if i put it right before the new scene. Thanks again Alex, pretty appreciate your help :D
Gonna study more about the Renpy Documentation, sorry if i do stupids questions xD

Post Reply

Who is online

Users browsing this forum: Andredron