How to re use the same image?

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
Mimiruns
Regular
Posts: 48
Joined: Sun Jan 17, 2016 3:32 am
Contact:

How to re use the same image?

#1 Post by Mimiruns »

Is there a way you can reuse an image that you have already defined? Like I used a "show [imagine" once, and I want to reuse the same picture again later on. Can I simply just reuse the same code I did or would I have to redefine the same image under a new name every time?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1460
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: How to re use the same image?

#2 Post by xavimat »

(I don't understand what is the [ doing in your code)

You define the images at init time (before anything is shown to the player)
In the game you can show and hide your images any time you need (with show, hide and scene). See the quick start in the documentation and the example "the question".
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: How to re use the same image?

#3 Post by johandark »

Here is the 2 images. One with girl talking and the other with the girl silent.

Code: Select all

image Girl_Silent = "images/day01/girl_silent.png"
image Girl_Talking = "images/day01/girl_talking.png"
Here just different kind of conversations, so there is a reason to be quiet.

Code: Select all

define girl = Character("Girl", color="#dfa8a8")
define girl_thoughts = Character("Girl Thoughts", color="#dfa8a8")
and here an example.

Code: Select all

label start:
    show Girl_Talking with fade
    girl "Wow! What a nice day!"

    show Girl_Silent with dissolve
    girl_thouthts "What the hell is he thinking about?"

    show Girl_Talking with dissolve
    girl "I guess you are wondering what I´m doing with this dress don´t you?"

    show Girl_Silent with dissolve
    girl_thouthts "Why the hell is so silent?"

    return
I gues that´s what you were asking...
Image

Mimiruns
Regular
Posts: 48
Joined: Sun Jan 17, 2016 3:32 am
Contact:

Re: How to re use the same image?

#4 Post by Mimiruns »

Yes that's exactly what I mean, I guess I should post an example of what I want.

Normally when I want to reuse the exact same image later, I have to make different named versions of the same picture. Like this

Code: Select all

image Girl_Silent1 = "girl_silent.png"
image Girl_Silent2 = "girl_silent.png"
And so on. I won't want to have to ad on another number every time I want to reuse the same exact image. Is there a way I can just reuse one image?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to re use the same image?

#5 Post by trooper6 »

I'm still a bit unclear as to what exactly you want.

Do you want to show the same image more than one time (one time now, one time later), or do you want to have the same image on the screen more than once at the same time?

If you just want to show an image once now and then once later, without it being on the screen twice at the same time, you don't have to declare it twice...you just have to show it...the program doesn't forget the image.

Code: Select all

image Girl_Silent = "images/girl_silent.png"

label start:
    scene park
    show Girl_Silent at center
    mc "Hello silent girl, how are you."
    "The silent girl says nothing."
    mc "How rude, I'm leaving."

label home:
    scene home
    mc "I'm so glad to be home. Hey what's that sound?"
    "You look in your closet, and there...."
    show Girl_Silent at center
    "...the silent girl is waiting for you!"
You don't have to do anything special. You just show the image when you want to see the image, hide it when you don't.

Or do you want to have two silent girls on the screen at the same time?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Mimiruns
Regular
Posts: 48
Joined: Sun Jan 17, 2016 3:32 am
Contact:

Re: How to re use the same image?

#6 Post by Mimiruns »

Yes I want to show the same image more than once without having to declare it multiple times to reuse an image.

I don't use sprites, I use whole pictures. And I want to be able to use the same picture multiple times. Almost like the same scene.

For example

Code: Select all

image D7 = "Diamondstanding1.jpg"
image D8 = "Diamondstanding1.jpg"
image D9 = "Diamondstanding1.jpg"
This is all for the same image. I want to be able to not have to declare the same image multiple times in order to reuse it. IS there any way to declare an image once to be be able to reuse it?

User avatar
Donmai
Eileen-Class Veteran
Posts: 1958
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: How to re use the same image?

#7 Post by Donmai »

trooper6 just answered your question.
trooper6 wrote:If you just want to show an image once now and then once later, without it being on the screen twice at the same time, you don't have to declare it twice...you just have to show it...the program doesn't forget the image.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

Mimiruns
Regular
Posts: 48
Joined: Sun Jan 17, 2016 3:32 am
Contact:

Re: How to re use the same image?

#8 Post by Mimiruns »

No no, I don't think that's it.

The problem I'm having is, I think you can only use an image declaration once.

The way I want to do it in my head is

Code: Select all

image D1 = "Diamondstanding1.jpg"
So I have my declared image here. and now here is the script I want to use. These are not sprites but whole pictures I'm using in a slide-show type of format.
Show D1

D "blahblah"

show some other scene

D "Blahblahblah"

show D1
Whenever I do that, the image wont' show. It will only allow me to use an image declaration once, if I want to reuse the same image, I will have to declare it again but under a different name, so I just rename it to something like D2 and D3 and so on. Is there a way I can declare an image once and just reuse the shorthand code for it? Or do I simply have to declare an image under multiple names for it's unique one use.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to re use the same image?

#9 Post by trooper6 »

Mimiruns wrote:No no, I don't think that's it.
That is it.
Mimiruns wrote:The problem I'm having is, I think you can only use an image declaration once.
That isn't what is happening with your code. Let's look at your code in detail...

Code: Select all

image D1 = "Diamondstanding1.jpg" #Line 1
image D2 = "Diamondstanding2.jpg" #Line 2

label start:
    show D1 #Line 3

    D "blahblah" #Line 4

    show D2 #Line 5

    D "Blahblahblah" #Line 6

    show D1 #Line 7
So what is happening in your code as you have written in?

In line 1 & 2, you declare two different images.
In line 3 you show a full screen slide, D1
In line 5 you show a second full screen slide, D2, on top D1. D1 is still on the screen because you haven't hidden it, you just can't see it because it is underneath D2.
In line 7 who show D1 again. D1 is, however already showing, it is underneath D2.

So, you need to hide your images when you are done with them.

Code: Select all

image D1 = "Diamondstanding1.jpg"
image D2 = "Diamondstanding2.jpg" 

label start:
    show D1 

    D "blahblah" 

    hide D1
    show D2 

    D "Blahblahblah" 

    hide D2
    show D1 
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Donmai
Eileen-Class Veteran
Posts: 1958
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: How to re use the same image?

#10 Post by Donmai »

Adding to what trooper6 told you: you could use a name tag to automatically hide an image when you show another. When you show an image, it will always overwrite any previous image with the same name tag. So:

Code: Select all

image sld D1 = "Diamondstanding1.jpg" 
image sld D2 = "Diamondstanding2.jpg" 

label start:
    show sld D1 # in this case, "sld" is the name tag. Can be anything you prefer
    D "blahblah" 

    show sld D2 
    D "Blahblahblah" 

    show sld D1
    D "Blahblahblahblahblah" 
https://www.renpy.org/doc/html/displayi ... html#image
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

Mimiruns
Regular
Posts: 48
Joined: Sun Jan 17, 2016 3:32 am
Contact:

Re: How to re use the same image?

#11 Post by Mimiruns »

OhhI think I finally understand now.

Thank you so much! And thanks for bearing with me lol.

Post Reply

Who is online

Users browsing this forum: No registered users