[Solved]Hide image in 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
User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

[Solved]Hide image in screen

#1 Post by bonnie_641 »

When I add an image to a screen:

Code: Select all

screen show_image:
add image_
But... This image is " pinned" to a large number of events (with DynamicImage).
Nowhere do I find a solution.

Code: Select all

default avatar = 1
image token: <----------------------------------This image
    DynamicImage("token[avatar]" )
    size (50,50)
Example of one of the many events...

Code: Select all

# for moving left
        if x>0: # check if player is not at the left side of field
     
            if gf[y][x-1] != 1: # check if tile at left is not 0
                
                
                key "focus_left" action [SetVariable("x", max(x-1, 0)), SetVariable("avatar", 1), SetScreenVariable("my_var", 0)] # <-------added a SetVariable for avatar
            else:
                key "focus_left" action NullAction()
Base on which the player's image appears on screen

Code: Select all

# player's token
        grid 22 12:
            align gf_align
            at my_tr
           
            for py in range(12):
                for px in range(22):

                    if py == y and px == x:

                        add "token[avatar]" : #<-------------------here
                            if gf[y][x] == 2: #si es tile_2...
                                offset (20, -20) # that is 20 pxls to the right and 20 pxls up

Last edited by bonnie_641 on Thu Aug 15, 2019 7:48 am, edited 1 time in total.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Hide image in screen

#2 Post by Kia »

the images case is simple, it's either shown or not. it can be managed by a single variable:

Code: Select all

if show_image:
    add image_
and you can change that variable in the rest of your code.
or you can check the other conditions right inside your screens:

Code: Select all

if cond_1 == 3 and cond_2 == False or cond_3 > 0:
     if cond_5:
        add image_

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: Hide image in screen

#3 Post by bonnie_641 »

Thank you so much Kia :D
I'll finally be able to hide the image on a screen.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

Post Reply

Who is online

Users browsing this forum: Google [Bot]