Add a displayable to an existing screen

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
drmindflip
Newbie
Posts: 7
Joined: Thu Jun 18, 2020 8:15 pm
Contact:

Add a displayable to an existing screen

#1 Post by drmindflip »

I have a status bar screen at the top of my game. How do I add new interface elements (e.g. an imagebutton) to that screen during the game?

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

Re: Add a displayable to an existing screen

#2 Post by Alex »

That denends of what you want to show.
The easiest (but maybe not the most efficient) way is to put all the elements in your screen and make some variables to operate what to show and what not.
But if you have a list of elements to show (like some player stats), you can show the content of this list, so it will change while you add or remove elements in this list.

drmindflip
Newbie
Posts: 7
Joined: Thu Jun 18, 2020 8:15 pm
Contact:

Re: Add a displayable to an existing screen

#3 Post by drmindflip »

That sounds ok Alex, I can do that thank you.

Basically, the screen in question is at the top of my display and I want to add little 'tabs' to represent status ailments during play - these can subsequently be clicked on to interact with them.

It would be lovely if I could use regular Renpy commands to show these tabs with little transitions, animations etc. I suppose I could dynamically make each tab a little independent 'screen' of its own, showing a single imagebutton, or is that a crazy idea?

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

Re: Add a displayable to an existing screen

#4 Post by Alex »

drmindflip wrote: Tue Jun 23, 2020 12:51 pm ... It would be lovely if I could use regular Renpy commands to show these tabs with little transitions, animations etc. I suppose I could dynamically make each tab a little independent 'screen' of its own, showing a single imagebutton, or is that a crazy idea?
You can make several screens (if all your elements have their own places on screen). Also check the 'showif' statement - https://www.renpy.org/doc/html/screens. ... -statement

drmindflip
Newbie
Posts: 7
Joined: Thu Jun 18, 2020 8:15 pm
Contact:

Re: Add a displayable to an existing screen

#5 Post by drmindflip »

Thanks a lot for your help! I'm using showif to add an new icon to the display everytime a new 'visitor' is added to the game (it's, broadly-speaking, a hospitality game)

Code: Select all

showif len(visitors)>0:
	python:
		for x in visitors:
			renpy.ui.imagebutton("icon"+str(x), action=Function(visitors.remove, x))
The above code adds a personalised icon for each visitor, and can be clicked on to remove the visitor. So far so good!

I have one more question that has been driving me crazy...how can I apply a transform to these imagebuttons when they are first generated only. I want to use easeintop, or equivalent, to have them slide down from the top of the screen. What's the best way to approach this?

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

Re: Add a displayable to an existing screen

#6 Post by Alex »

drmindflip wrote: Thu Jun 25, 2020 5:19 pm ...I have one more question that has been driving me crazy...how can I apply a transform to these imagebuttons when they are first generated only. ...
The example on the link has a transform, so try to make the same and play with 'on appear'/'on show' events.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]