Making sprites dissolve by default when shown

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
Ultra_HR
Regular
Posts: 39
Joined: Tue Dec 02, 2014 4:50 pm
Completed: Surkea, Arcadia, Cerulean
Projects: Missing Stars
Organization: Somnova Studios
IRC Nick: Ultra_HR
Contact:

Making sprites dissolve by default when shown

#1 Post by Ultra_HR »

Hi. I'm trying to figure out how to make sprites dissolve by default when shown, so it is not necessary to write "with dissolve" after every show statement. I've found this thread on the subject: viewtopic.php?t=26221 and the code below almost works:

Code: Select all

    def replacement_show(*args, **kwargs):
        renpy.transition(dissolve)
        return renpy.show(*args, **kwargs)
    config.show = replacement_show

    def replacement_hide(*args, **kwargs):
        renpy.transition(dissolve)
        return renpy.hide(*args, **kwargs)
    config.hide = replacement_hide
But this results in text being dissolved when

Code: Select all

show
is used as well, as shown below:
Image

Using this code from further down the post:

Code: Select all

init python:
    def replacement_show(*args, **kwargs):
        renpy.transition(Dissolve(0.5))
        renpy.show(*args, **kwargs)
        renpy.pause(0.5, hard=False)
        return 
    config.show = replacement_show
    
    def replacement_hide(*args, **kwargs):
        renpy.transition(Dissolve(1))
        renpy.hide(*args, **kwargs)
        renpy.pause(0, hard=True)
        return 
    config.hide = replacement_hide
Also comes close, but results in each sprite being displayed in order rather than all at once, as shown below:
Image

There is

Code: Select all

config.say_attribute_transition
for making say statements with sprite changes always have a transition. Is there anything similar that can be done to make "show" statements dissolve by default, so one doesn't have to write "with dissolve" every few lines? If not, does anybody know how I could adapt the code above to make it work as desired?
I'm the writing lead for Somnova Studios and the Annaliese route writer for Missing Stars. You can play Act 1 now. I also co-wrote Arcadia and did programming for Cerulean.

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Making sprites dissolve by default when shown

#2 Post by morganw »

Ultra_HR wrote: Tue Nov 13, 2018 8:23 pm Using this code from further down the post:

Code: Select all

init python:
    def replacement_show(*args, **kwargs):
        renpy.transition(Dissolve(0.5))
        renpy.show(*args, **kwargs)
        renpy.pause(0.5, hard=False)
        return 
    config.show = replacement_show
    
    def replacement_hide(*args, **kwargs):
        renpy.transition(Dissolve(1))
        renpy.hide(*args, **kwargs)
        renpy.pause(0, hard=True)
        return 
    config.hide = replacement_hide
Also comes close, but results in each sprite being displayed in order rather than all at once
Did you try removing the renpy.pause calls?

User avatar
Ultra_HR
Regular
Posts: 39
Joined: Tue Dec 02, 2014 4:50 pm
Completed: Surkea, Arcadia, Cerulean
Projects: Missing Stars
Organization: Somnova Studios
IRC Nick: Ultra_HR
Contact:

Re: Making sprites dissolve by default when shown

#3 Post by Ultra_HR »

morganw wrote: Wed Nov 14, 2018 3:22 pm Did you try removing the renpy.pause calls?
Good idea, but doing so re-introduces the issue where text fades in;
Image
I'm the writing lead for Somnova Studios and the Annaliese route writer for Missing Stars. You can play Act 1 now. I also co-wrote Arcadia and did programming for Cerulean.

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Making sprites dissolve by default when shown

#4 Post by morganw »

Ah, right, I didn't notice that removing those puts you back where you started.

I think that because show is used for more than just defined images, and because the transition is a separate thing from what you are showing, it'll be quite tricky. You can probably do it by checking *args and **kwargs and only requesting the transition if the image is one of the characters, instead of always requesting the transition. Whether this is a good idea or not probably depends on how easy it is to identify a character from anything else. The image name would just be the first argument, so maybe that would be enough.

User avatar
Ultra_HR
Regular
Posts: 39
Joined: Tue Dec 02, 2014 4:50 pm
Completed: Surkea, Arcadia, Cerulean
Projects: Missing Stars
Organization: Somnova Studios
IRC Nick: Ultra_HR
Contact:

Re: Making sprites dissolve by default when shown

#5 Post by Ultra_HR »

morganw wrote: Thu Nov 15, 2018 2:23 pm Ah, right, I didn't notice that removing those puts you back where you started.

I think that because show is used for more than just defined images, and because the transition is a separate thing from what you are showing, it'll be quite tricky. You can probably do it by checking *args and **kwargs and only requesting the transition if the image is one of the characters, instead of always requesting the transition. Whether this is a good idea or not probably depends on how easy it is to identify a character from anything else. The image name would just be the first argument, so maybe that would be enough.
Thanks so much for this insight. Sorry to ask, but could you possibly provide an example of what you've suggested doing? I'm not sure where to begin.
I'm the writing lead for Somnova Studios and the Annaliese route writer for Missing Stars. You can play Act 1 now. I also co-wrote Arcadia and did programming for Cerulean.

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Making sprites dissolve by default when shown

#6 Post by morganw »

It looks like the reason the text gets the same effect is because the transition is applied to the whole layer, and the character is on the same layer as the text. So this is probably the easiest solution:

Code: Select all

init python:
    def replacement_show(*args, **kwargs):
        if kwargs['layer'] == 'characters':
            renpy.transition(Dissolve(5), layer=kwargs['layer'])
        renpy.show(*args, **kwargs)
        return 

    def replacement_scene(*args, **kwargs):
        renpy.scene('characters')
        renpy.scene(*args, **kwargs)
        return 
    
    config.layers = [ 'master', 'characters', 'transient', 'screens', 'overlay' ]
    config.tag_layer = { 'sylvie': 'characters' }
    config.show = replacement_show
    config.scene = replacement_scene
The key to this working is that you map the tags for your characters against the new 'characters' layer, so you don't have to specify a layer when you show them; the replacement show function will request a transition when it shows images on the new layer.

Replacing the scene function is optional, but stops you having to specify clearing the extra layer when you use 'scene' in the game script. The same issue will come up with anything else you do that defaults to working with the 'master' layer.

The transition is set to 5 seconds so it should be obvious if it is working or not, and if you paste the code into the top of the demo game you can try it out there first (this is where the 'sylvie' tag comes from).

User avatar
Ultra_HR
Regular
Posts: 39
Joined: Tue Dec 02, 2014 4:50 pm
Completed: Surkea, Arcadia, Cerulean
Projects: Missing Stars
Organization: Somnova Studios
IRC Nick: Ultra_HR
Contact:

Re: Making sprites dissolve by default when shown

#7 Post by Ultra_HR »

morganw wrote: Fri Nov 16, 2018 4:40 pm It looks like the reason the text gets the same effect is because the transition is applied to the whole layer, and the character is on the same layer as the text. So this is probably the easiest solution...
Thank you so much for your continued attention here, I really appreciate it.

This is so so close - the only problem is that putting this in place causes everything that isn't being transitioned to turn black for the duration of the transition - see below;
Image

I've tried tweaking a few things, but can't stop this from happening. Could I be terribly cheeky and ask if you've any idea why that might be happening?

Just in case it's of importance - I fear I perhaps ought to have mentioned this before - this project is using Ren'Py version 6.99.12.4 rather than the latest, because reasons.
I'm the writing lead for Somnova Studios and the Annaliese route writer for Missing Stars. You can play Act 1 now. I also co-wrote Arcadia and did programming for Cerulean.

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Making sprites dissolve by default when shown

#8 Post by morganw »

Does the same thing happen if you don't set 'config.scene' ?

User avatar
Ultra_HR
Regular
Posts: 39
Joined: Tue Dec 02, 2014 4:50 pm
Completed: Surkea, Arcadia, Cerulean
Projects: Missing Stars
Organization: Somnova Studios
IRC Nick: Ultra_HR
Contact:

Re: Making sprites dissolve by default when shown

#9 Post by Ultra_HR »

morganw wrote: Sat Nov 17, 2018 10:06 am Does the same thing happen if you don't set 'config.scene' ?
I'm afraid so, yes.
I'm the writing lead for Somnova Studios and the Annaliese route writer for Missing Stars. You can play Act 1 now. I also co-wrote Arcadia and did programming for Cerulean.

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Making sprites dissolve by default when shown

#10 Post by morganw »

What is the transition you are using?

User avatar
Ultra_HR
Regular
Posts: 39
Joined: Tue Dec 02, 2014 4:50 pm
Completed: Surkea, Arcadia, Cerulean
Projects: Missing Stars
Organization: Somnova Studios
IRC Nick: Ultra_HR
Contact:

Re: Making sprites dissolve by default when shown

#11 Post by Ultra_HR »

morganw wrote: Sat Nov 17, 2018 4:51 pm What is the transition you are using?
Just dissolve. Here's the full code I've got for this customised show statement etc.:

Code: Select all

init python:
    def replacement_show(*args, **kwargs):
        if kwargs['layer'] == 'characters':
            renpy.transition(Dissolve(1), layer=kwargs['layer'])
        renpy.show(*args, **kwargs)
        return
    
    config.layers = [ 'master', 'characters', 'transient', 'screens', 'overlay' ]
    config.tag_layer = { 'kura': 'characters' }
    config.tag_layer = { 'oni': 'characters' }
    config.tag_layer = { 'utagu': 'characters' }
    config.tag_layer = { 'kokoro': 'characters' }
    config.show = replacement_show
And here are the two lines for the dialogue in that gif:

Code: Select all

    "As we chatter along, Oni sits up slowly, idly rubbing the sleep from her eye."
    show kokoro smile
I'm the writing lead for Somnova Studios and the Annaliese route writer for Missing Stars. You can play Act 1 now. I also co-wrote Arcadia and did programming for Cerulean.

morganw
Regular
Posts: 51
Joined: Fri Nov 20, 2015 7:00 pm
Contact:

Re: Making sprites dissolve by default when shown

#12 Post by morganw »

config.tag_layer is a dictionary, so I think it should look like this:

Code: Select all

config.tag_layer = {'kura': 'characters',
                    'oni': 'characters',
                    'utagu': 'characters',
                    'kokoro': 'characters'}
I'm not sure why the background would have gone black, but 3/4 characters wouldn't have been using the layer.
If you try the above, does that change anything?

Post Reply

Who is online

Users browsing this forum: No registered users