Ren'Py Dumb question about char transition

coffeeaddicted

Well-Known Member
Apr 13, 2021
1,826
1,481
With dissolve a sprite transitions first out then in.
So there is a gap where the first sprite dissolve entirely before the new sprite transitions in with dissolve.
This looks pretty off as there is nothing in between.

To make it appear that the sprite is always there and just transitions i had to reverse the order to make the character not vanish.

So instead of
hide pic01 with dissolve
show pic02 with dissolve

i did this
show pic03 with dissolve
hide pic01 with dissolve

I am sure that is not how it should be.

Is there another way to keep the previous sprite until the new one is drawn?

Thank you
 

MidnightArrow

Active Member
Aug 22, 2021
500
451
If images have the same tag they'll replace each other. So name your images/variables better.

"show some_chara happy with dissolve" will take the place of "some_chara" without needing a hide statement.
 
  • Like
Reactions: osanaiko

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
You mentioned "sprites", so I'll assume my standard answer of "don't use show/hide, use scene instead" doesn't apply.

What I think you might be aiming towards is RenPy's idea of .

Short version: If your displayables (your images) are defined by using names with spaces in them, RenPy will use the first part of the image name as a "tag" and the other parts of the name as "attributes".

So for example image mary beach night happy = ..., mary is the image tag, beach, night and happy are attributes.

The reason I'm mentioning all of this is that there can only be ONE mary image on screen at any given point. Each tag must be unique.

And before you go off and rename all your images to include spaces in the their names... you don't need to (and honestly, it's probably a bad idea to too).
There's an config option called "automatic_images" - which for some reason is no longer documented.

Add these lines into your options.rpy file...

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images' ]

These two lines will mean that filenames with underscores or hyphens, etc will automatically be converted to tag/attribute style names.

For example:

images/mary_beach_night_happy.png will auto generate a displayable called mary, beach night happy, without you needing to manually assign it in your code.

What all that then means is that if you name your files like:
  • images/mysprite_pic01.png
  • images/mysprite_pic02.png
  • images/mysprite_pic03.png

You can simply code:

Code:
scene myscene001 with fade

show mysprite pic01 with dissolve
show mysprite pic02 with dissolve
show mysprite pic03 with dissolve

scene myscene002 with dissolve

#etc.

A reminder: Using scene will remove all previously shown images added to the scene by using show, without the need to hide them.

In this case, each mysprite will replace the previous one. Generally the first part of the name would be to uniquely identify the sprite. So character names would be common (hence the example mary).

You may notice one of the auto-converted characters is "/". This is to allow for folder/directory names to be part of the displayable name/tag/attributes too.

So for example, using...

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images' , 'sprites']

Would mean you could put your files into subfolders like:
  • images/sprites/mary/beach_night_happy.png - > mary beach night happy
  • images/sprites/mary/beach_day_happy.png - > mary beach day happy
  • images/sprites/mary/school_day_happy.png - > mary - school day happy
  • images/sprites/mary/school_day_sad.png - > mary - school day sad
 
Last edited:

coffeeaddicted

Well-Known Member
Apr 13, 2021
1,826
1,481
You mentioned "sprites", so I'll assume my standard answer of "don't use show/hide, use scene instead" doesn't apply.

What I think you might be aiming towards is RenPy's idea of .

Short version: If your displayables (your images) are defined by using names with spaces in them, RenPy will use the first part of the image name as a "tag" and the other parts of the name as "attributes".

So for example image mary beach night happy = ..., mary is the image tag, beach, night and happy are attributes.

The reason I'm mentioning all of this is that there can only be ONE mary image on screen at any given point. Each tag must be unique.

And before you go off and rename all your images to include spaces in the their names... you don't need to (and honestly, it's probably a bad idea to too).
There's an config option called "automatic_images" - which for some reason is no longer documented.

Add these lines into your options.rpy file...

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images' ]

These two lines will mean that filenames with underscores or hyphens, etc will automatically be converted to tag/attribute style names.

For example:

images/mary_beach_night_happy.png will auto generate a displayable called mary, beach night happy, without you needing to manually assign it in your code.

What all that then means is that if you name your files like:
  • images/mysprite_pic01.png
  • images/mysprite_pic02.png
  • images/mysprite_pic03.png

You can simply code:

Code:
scene myscene001 with fade

show mysprite pic01 with dissolve
show mysprite pic02 with dissolve
show mysprite pic03 with dissolve

scene myscene002 with dissolve

#etc.

A reminder: Using scene will remove all previously shown images added to the scene by using show, without the need to hide them.

In this case, each mysprite will replace the previous one. Generally the first part of the name would be to uniquely identify the sprite. So character names would be common (hence the example mary).

You may notice one of the auto-converted characters is "/". This is to allow for folder/directory names to be part of the displayable name/tag/attributes too.

So for example, using...

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images' , 'sprites']

Would mean you could put your files into subfolders like:
  • images/sprites/mary/beach_night_happy.png - > mary beach night happy
  • images/sprites/mary/beach_day_happy.png - > mary beach day happy
  • images/sprites/mary/school_day_happy.png - > mary - school day happy
  • images/sprites/mary/school_day_sad.png - > mary - school day sad
This worked. Wow...
I never thought off that but i knew from reading previously that you can do that but i always ignored it.

The reason i am using sprites in some scenes is, when a character talks to itself or is in a conversation, rather to have it rendered with the whole scene, it made sense to me to just have the sprite show up in front.
There is still a lot to be learned but i actually like it a lot.

Thanks for sharing. This made my life easier.
 

coffeeaddicted

Well-Known Member
Apr 13, 2021
1,826
1,481
You mentioned "sprites", so I'll assume my standard answer of "don't use show/hide, use scene instead" doesn't apply.

What I think you might be aiming towards is RenPy's idea of .

Short version: If your displayables (your images) are defined by using names with spaces in them, RenPy will use the first part of the image name as a "tag" and the other parts of the name as "attributes".

So for example image mary beach night happy = ..., mary is the image tag, beach, night and happy are attributes.

The reason I'm mentioning all of this is that there can only be ONE mary image on screen at any given point. Each tag must be unique.

And before you go off and rename all your images to include spaces in the their names... you don't need to (and honestly, it's probably a bad idea to too).
There's an config option called "automatic_images" - which for some reason is no longer documented.

Add these lines into your options.rpy file...

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images' ]

These two lines will mean that filenames with underscores or hyphens, etc will automatically be converted to tag/attribute style names.

For example:

images/mary_beach_night_happy.png will auto generate a displayable called mary, beach night happy, without you needing to manually assign it in your code.

What all that then means is that if you name your files like:
  • images/mysprite_pic01.png
  • images/mysprite_pic02.png
  • images/mysprite_pic03.png

You can simply code:

Code:
scene myscene001 with fade

show mysprite pic01 with dissolve
show mysprite pic02 with dissolve
show mysprite pic03 with dissolve

scene myscene002 with dissolve

#etc.

A reminder: Using scene will remove all previously shown images added to the scene by using show, without the need to hide them.

In this case, each mysprite will replace the previous one. Generally the first part of the name would be to uniquely identify the sprite. So character names would be common (hence the example mary).

You may notice one of the auto-converted characters is "/". This is to allow for folder/directory names to be part of the displayable name/tag/attributes too.

So for example, using...

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images' , 'sprites']

Would mean you could put your files into subfolders like:
  • images/sprites/mary/beach_night_happy.png - > mary beach night happy
  • images/sprites/mary/beach_day_happy.png - > mary beach day happy
  • images/sprites/mary/school_day_happy.png - > mary - school day happy
  • images/sprites/mary/school_day_sad.png - > mary - school day sad
Well, the transition works but it seems that the images are stacked.

So maybe my brain isn't working as it should but my files are simply 'momxx' which are the sprites.
Do they need to be defined as an imagine?

The transition is good and the only reason i know that there several layers is that the hair grows over time.
I only have one background. So there isn't a refresh.

I have to dig a little more since its late already. Amazing how quick time passes when you ponder. :)
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
Well, the transition works but it seems that the images are stacked.

So maybe my brain isn't working as it should but my files are simply 'momxx' which are the sprites.
Do they need to be defined as an imagine?

If they're stacked, it's likely because you aren't using names which resolve into "tag" and "attributes".
If the files were:
  • mom01.png
  • mom02.png
  • mom03.png

Then that's three different "tags" with no attributes (mom01, mom02, mom03).

If you renamed the files to be:
  • mom_01.png
  • mom_02.png
  • mom_03.png

(and included the two automatic_images lines I mentioned earlier)
Then that would be ONE tag ("mom" with different attributes (01, 02, 03).

Again, without the automatic image lines in the options file and how it swaps characters like "_" to spaces, it'd still be three separate image tags.

It's the fact they're all tagged with the same name/id ("mom") that stops the stacking and means only one "mom" image is shown on screen at any given moment.
 
  • Like
Reactions: coffeeaddicted

coffeeaddicted

Well-Known Member
Apr 13, 2021
1,826
1,481
If they're stacked, it's likely because you aren't using names which resolve into "tag" and "attributes".
If the files were:
  • mom01.png
  • mom02.png
  • mom03.png

Then that's three different "tags" with no attributes (mom01, mom02, mom03).

If you renamed the files to be:
  • mom_01.png
  • mom_02.png
  • mom_03.png

(and included the two automatic_images lines I mentioned earlier)
Then that would be ONE tag ("mom" with different attributes (01, 02, 03).

Again, without the automatic image lines in the options file and how it swaps characters like "_" to spaces, it'd still be three separate image tags.

It's the fact they're all tagged with the same name/id ("mom") that stops the stacking and means only one "mom" image is shown on screen at any given moment.
Got it. So the name of the files has to have an underscore in order to work.
Let me try that.

I have to think about the file naming in general i think.

Thanks again

p.s. the strangest thing happened.
It did not work with the renaming either. At least not with the underscore.
So i did a test.
When i renamed the file "mom 01.png" it did work. Last image was taken out while new image was put on top without a gap. Now i wonder if the define in options did not work and why.
What i can say is that it does work if i rename the files without the underscore.
Maybe something changed in RenPy?

Thank you
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
Got it. So the name of the files has to have an underscore in order to work.

AND you need the two configuration variables set to convert those underscores to spaces.

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images']

The important thing is that RenPy automatically generates displayable names that it can recognize as tags+attributes, separated by spaces.

Let's assume three single displayable/image filenames:
  • D:\Dev\RenPy\Locked and Loaded\game\images\mom_22.png
  • D:\Dev\RenPy\Locked and Loaded\game\images\mom33.png
  • D:\Dev\RenPy\Locked and Loaded\game\images\mom_44_night.png

Where D:\Dev\RenPy\ is the folder where I store my RenPy projects.
And Locked and Loaded is the name of my imaginary game.

Normal RenPy logic:

Normally, RenPy goes through the game's /game/ folder and sub-folders and generates a displayable for any images or videos it finds, with a name that matches the filename (omitting the file path and the file extension).

Auto-Generated displayableimage tagimage attributes
image mom_22 = "images/mom_22.png"mom_22
image mom33 = "images/mom33.png"mom33
image mom_44_night = "images/mom_44_night.png"mom_44_night


WITH config.automatic_images and config.automatic_images_strip set.

Auto-Generated displayableimage tagimage attributes
image mom 22 = "images/mom_22.png"mom22
image mom33 = "images/mom33.png"mom33
image mom 44 night = "images/mom_44_night.png"mom44 night


Everything else I talked about (and now you understand it a little better, you might want to re-read the original post) was about organizing your images files into folders and sub-folders, if that makes sense for your game.

As a completely separate topic, I would HIGHLY recommend that all developers name all their files to be 100% lowercase. RenPy displayables are always generated in lowercase, so it makes sense for the filenames to match them as much as possible.
 

coffeeaddicted

Well-Known Member
Apr 13, 2021
1,826
1,481
AND you need the two configuration variables set to convert those underscores to spaces.

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images']

The important thing is that RenPy automatically generates displayable names that it can recognize as tags+attributes, separated by spaces.

Let's assume three single displayable/image filenames:
  • D:\Dev\RenPy\Locked and Loaded\game\images\mom_22.png
  • D:\Dev\RenPy\Locked and Loaded\game\images\mom33.png
  • D:\Dev\RenPy\Locked and Loaded\game\images\mom_44_night.png

Where D:\Dev\RenPy\ is the folder where I store my RenPy projects.
And Locked and Loaded is the name of my imaginary game.

Normal RenPy logic:

Normally, RenPy goes through the game's /game/ folder and sub-folders and generates a displayable for any images or videos it finds, with a name that matches the filename (omitting the file path and the file extension).

Auto-Generated displayableimage tagimage attributes
image mom_22 = "images/mom_22.png"mom_22
image mom33 = "images/mom33.png"mom33
image mom_44_night = "images/mom_44_night.png"mom_44_night


WITH config.automatic_images and config.automatic_images_strip set.

Auto-Generated displayableimage tagimage attributes
image mom 22 = "images/mom_22.png"mom22
image mom33 = "images/mom33.png"mom33
image mom 44 night = "images/mom_44_night.png"mom44 night


Everything else I talked about (and now you understand it a little better, you might want to re-read the original post) was about organizing your images files into folders and sub-folders, if that makes sense for your game.

As a completely separate topic, I would HIGHLY recommend that all developers name all their files to be 100% lowercase. RenPy displayables are always generated in lowercase, so it makes sense for the filenames to match them as much as possible.

First, thank you for your patience.
I may seem a little slow.

I think i get it but i did all that. Mostly.

File names are always lowercase in my game.
I added the define in the options.rpy but it seems it won't recognize the tag and so declared the image in the script file.

Code:
image mom 01 = "images/sprites/mom_01.png"
That way, Renpy seems to know what the tag means in relation to the image file.
If i don't do that, it won't find the image or can't load it.

Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images']
This is the option at the end in my case but it should still recognize it.

So, not sure if the define doesn't work with the RenPy version i have (8.0.3) but it seems not to do it.
Of course, manual does work.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,611
2,258
I added the define in the options.rpy but it seems it won't recognize the tag and so declared the image in the script file.
[...]
So, not sure if the define doesn't work with the RenPy version i have (8.0.3) but it seems not to do it.

I just tested it with RenPy 7.5.0 and 8.0.3 - both work as I described.

Code:
image mom 01 = "images/sprites/mom_01.png"
# -and-
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images']

Because you've switched on the "automatic images" logic, it's processing the whole filename (within /game/ folder).

Your filename is images/sprites/mom_01.png
You've told it to ignore "images", "/" and "_"

So it's auto-generated this instead:
define sprites mom 01 = "images/sprites/mom_01.png"

Where the tag is sprites and not mom as you has hoped.

Nice easy fix...

Do this instead:
Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images', 'sprites' ]
 
  • Like
Reactions: coffeeaddicted

coffeeaddicted

Well-Known Member
Apr 13, 2021
1,826
1,481
I just tested it with RenPy 7.5.0 and 8.0.3 - both work as I described.




Because you've switched on the "automatic images" logic, it's processing the whole filename (within /game/ folder).

Your filename is images/sprites/mom_01.png
You've told it to ignore "images", "/" and "_"

So it's auto-generated this instead:
define sprites mom 01 = "images/sprites/mom_01.png"

Where the tag is sprites and not mom as you has hoped.

Nice easy fix...

Do this instead:
Python:
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = [ 'images', 'sprites' ]

Indeed. That did the trick. My oh my, i suppose i could have seen it but i didn't.

I really appreciate your time with me on this.
This works really like a charm. I may use expression statements as well to make more sense of the sprites.
At least now i know how it works. To be honest, i always avoided.

Thank you so much ;)