Change picture/expression?

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
Lucky Duck
Regular
Posts: 32
Joined: Fri Dec 15, 2017 5:08 am
Deviantart: AdamAnimationz
Skype: theluckiestofpone@gmail.com
Contact:

Change picture/expression?

#1 Post by Lucky Duck »

Hey there! I'm curious to ask, how do you change a characters picture/expression?

I currently have;

"image ex = "exampleimage.png" its an example c:

then "show ex" so it shows it, but how can i delete it and have another image take its place, and im afraid of doing a disolve or a fade might make the image still there but just invisible, and i dont want the game filled with invisible images and lagging it, you know? ;-;

so how can i switch the example image for a different one at any time? without it displaying both images?

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Change picture/expression?

#2 Post by mitoky »

Thats what image tags and attributes are for. Simply speaking, there can only be one image with the same tag at a time, hence if you "show" an image with the same tag, the old gets replaced (hence not shown anymore).
I have explained imagetags here:
viewtopic.php?f=51&t=46330

If you have questions, feel free to ask!

Lucky Duck
Regular
Posts: 32
Joined: Fri Dec 15, 2017 5:08 am
Deviantart: AdamAnimationz
Skype: theluckiestofpone@gmail.com
Contact:

Re: Change picture/expression?

#3 Post by Lucky Duck »

Thank you ^^ i THINK, i got it c: so does the "hide" command actually delete it? cause again i dont want it actually still being there but just invisible ;-;

and i just show/hide to switch? c:

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Change picture/expression?

#4 Post by mitoky »

Yes, but hide only needs to be used rarely.
Like, if you want a character to have change an expression, you simply use "show" because due to the tag, the old image gets replaces/hides (as as you would say, 'deletes') and the new image is the only one showing. There is no need to use hide here.
Basically, its takes its place, so there is no invisible picture, but only one which simply changes. Only one image of the same tag can 'exist' at the same time, so you dont have to worry there are invisible ones.

When you want to completly remove something, like when a character leaves a scene, then you use hide. Additionally, if you visually show that a character leaves (for example, by moving them 'off' screen) then remember to use hide.

So simply always make sure that images which switch/should not exist at the same time have the same tag.

Lucky Duck
Regular
Posts: 32
Joined: Fri Dec 15, 2017 5:08 am
Deviantart: AdamAnimationz
Skype: theluckiestofpone@gmail.com
Contact:

Re: Change picture/expression?

#5 Post by Lucky Duck »

This is currently my script, everything works perfectly fine now, i got it to hide and show, but i just want to know, am i using it correctly? i mean its working completly fine ^^ but, im just curious if the hide is used right?

Code: Select all

# People
define t = Character("Twilight Sparkle")

# BackGrounds

# Characters

image th = "Twilight Happy.png"
image ts = "Twilight Secret.png"
image ta = "Twilight Angry.png"

# The game starts here.
label start:

    show ts

    t "Welcome Fellow Pony"

    hide ts

    show th

    t "Sorry To Ask Such Things But..."

    t "Which do you belong to?"

    menu:
        "Earth Pony":
            jump epony

        "Unicron":
            jump upony

        "Pegasis":
            jump ppony

    label epony:

        t "Ah.. So Your An Earth Pony?"

        return

    label upony:

        hide th

        show ta

        t "Oh.. A Unicorn"

        return

    label ppony:

        t "ohh a pegasis?"

    return

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Change picture/expression?

#6 Post by mitoky »

You are using hide after everytime, so i wouldnt say its very practical. make the expressions the same tag and diffrent attributes. Like this:

Code: Select all

# People
define t = Character("Twilight Sparkle")

# BackGrounds

# Characters

image twilight happy = "Twilight Happy.png"
image twilight sad = "Twilight Secret.png"
image twilight angry = "Twilight Angry.png"

# The game starts here.
label start:

    show twilight sad

    t "Welcome Fellow Pony"

    show twilight happy

    t "Sorry To Ask Such Things But..."

    t "Which do you belong to?"

    menu:
        "Earth Pony":
            jump epony

        "Unicron":
            jump upony

        "Pegasis":
            jump ppony

    label epony:

        t "Ah.. So Your An Earth Pony?"

        return

    label upony:

        show twilight angry

        t "Oh.. A Unicorn"

        return

    label ppony:

        t "ohh a pegasis?"

    return
the images, for teh same charcater, have the same tag:

Code: Select all

image twilight happy = "Twilight Happy.png"
image twilight sad = "Twilight Secret.png"
image twilight angry = "Twilight Angry.png"
"twilight" is the tag. Ehe second, third words etc after are the attributes. So 'happy", "sad", "angry" are the attributes.

You dont have to hide the image. If you have images of the same tag (all twlight images with diffrent expressions), showing one automatically replaces the other. Only one image of same tag can be shown at once. Hence if you show "twilight happy" you cant show "twilight sad" at the same time, due to the same tag.

You only have to hide an image when the image completly goes away' for now. Like when a charcater leaves a scene while the scene goes on.

A tag/attribute is a seperate word, either with numbers or underscores in the middle etc.

Lucky Duck
Regular
Posts: 32
Joined: Fri Dec 15, 2017 5:08 am
Deviantart: AdamAnimationz
Skype: theluckiestofpone@gmail.com
Contact:

Re: Change picture/expression?

#7 Post by Lucky Duck »

Thank you ^^ im still really really confused on that.. ;-; but i copied your script and it worked the same, but if the way you wrote it is better and more pratical then, i'll try learning that way ^^

is there an easier way to explain it? sorry ^^'' and when you say "You only have to hide an image when the image completly goes away" does this mean the image is still in the game/scene but just invisible? cause again i dont want it lagging from having like 999999 pictures but you just cant see them ;-;

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Change picture/expression?

#8 Post by RicharDann »

It's very unlikely that lag occurs due to 'invisible' images on screen, it's actually the opposite, the more stuff is being showed the more the game might lag. Even then, Ren'Py rarely lags unless you're using a really slow PC, or if you're displaying an unreasonable amount of images, animations and other fancy stuff all at once.

What hide does with the image is, in a sense, 'delete' it, not from your game archives, but from the game's active memory and what's currently showing on the game screen.

EDIT: Deleting my somewhat short explanation in favor of mitoky's, wich does explain a lot more and will probably be easier to understand.
Last edited by RicharDann on Mon Dec 18, 2017 4:42 pm, edited 3 times in total.
The most important step is always the next one.

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Change picture/expression?

#9 Post by mitoky »

No problem, i can explain it diffrently. (:

Do lets say you have twilight one the screen in the scene, and you change expressions for twilight.
I made a small example:

Code: Select all

# People
define t = Character("Twilight Sparkle")

# Characters

image twilight happy = "Twilight Happy.png"
image twilight sad = "Twilight Secret.png"
image twilight angry = "Twilight Angry.png"

# The game starts here.
label start:

    show twilight sad

    t "Hello, i am twilight and i was but..."

    show twilight happy

    t "now that you are here i am happy!"

    return
Twilight has the tag 'twilight'. When you simply plan to change the image (like changing the expression) then you use the tag (in this case "twilight") and the changing attribute (which is what comes after the tag, in this case its the expressions "happy" and "sad").

So, when you use "show twilight happy" while "twilight sad" is still on teh screen, then the game knows : "Ok, so the image twilight it being replaced."
And thats the diffrence. The image 'twilight sad" swiches places with "twilight happy". Hence, twilight sad dissapears while twilight happy is showing.
The image "twilight sad" is gone and "twilight happy" is showing.
So if you show and image which has the tag "twilight" while another image with the same tag is currently displayed, the image will dissapear by default since images with the same tag cannot exist at the same time on screen. So you dont have to worry its still there, because it definitely is not.

What i meant with hide is not related to changing expressions but rather to content. Lets say you have a scene in which 2 character are talking with twilight, but twilight has to go home, for example. Then you dont change the expression but simply remove the image from screen.
Example:

Code: Select all

label start:

    show twilight sad

    t "Sadly, i have to go now."

    show twilight happy

    t "But i hope we can meet again soon. Bye!"
    
    hide twilight
    
    "It was nice meeting her!"

    return
So the diffrence is:

Using show with the image tag: Replaces. Old image is removed and replaced with the new image.
Using hide: Removes. Used when the character in game leaves in the middle of the scene.

Lucky Duck
Regular
Posts: 32
Joined: Fri Dec 15, 2017 5:08 am
Deviantart: AdamAnimationz
Skype: theluckiestofpone@gmail.com
Contact:

Re: Change picture/expression?

#10 Post by Lucky Duck »

Ohhhhhhh!!!! thank you so so much ^^ I get it now c: thank you so much ^^ that really helps c:

Much appreciated ^^

Post Reply

Who is online

Users browsing this forum: Google [Bot]