Some ATL and zorder questions... [SOLVED!]

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
Deji
Cheer Idol; Not Great at Secret Identities
Posts: 1592
Joined: Sat Oct 20, 2007 7:38 pm
Projects: http://bit.ly/2lieZsA
Organization: Sakevisual, Apple Cider, Mystery Parfait
Tumblr: DejiNyucu
Deviantart: DejiNyucu
Location: Chile
Contact:

Some ATL and zorder questions... [SOLVED!]

#1 Post by Deji »

So I have a bunch of characters on screen and I want them to "come front" when they speak, so you can "tell" which one is speaking.
So my first idea was to create a transform to do this, something like (sorry for the pseudocode)

Code: Select all

transform speak:
    zorder +3
    zoom 1.2

transform endspeak:
    zorder -3
    zoom 1

show characterA at speak
charA "this is me speaking! and I'm at front of everybody else now!"
show characterA at endspeak
show characterB at speak
charB "now I'm speaking and ideally, I'd like charA to go back to where they were before."

And I realised there's now way to do that with zorder ^^;
So what I'm doing right now is

Code: Select all

transform speak:
        zoom 1.1
        yoffset 50
transform endspeak:
        zoom 1
        yoffset 0

show charA zorder 3 at speak
ca "Hello! This is me speaking!"
show charA zorder 0 at endspeak
show charB zorder 3 at speak
cb "And now it's my turn to speak and charA has gone back to where they were"
Is there a more efficient way to do this?

Also, related:
I have a little bounce animation I use sometimes when characters speak

Code: Select all

transform bounce_up: 
        easeout 0.2 yoffset -30
        easein 0.2 yoffset 0
Problem is, when I zoom them in and adjust the yoffset, the animation goes to hell, because they end up in a higher position than when they started :'D
So ideally I'd like something like subtracting 30 to the current yoffset and them adding it back again instead.
Is that possible?

Thanks in advance! :3
Last edited by Deji on Sat Apr 04, 2015 10:40 pm, edited 1 time in total.
Image
Tumblr | Twitter
Forever busy :')
When drawing something, anything, USE REFERENCES!! Use your Google-fu!
Don't trust your memory, and don't blindly trust what others teach you either.
Research, observation, analysis, experimentation and practice are the key! (:

User avatar
Deji
Cheer Idol; Not Great at Secret Identities
Posts: 1592
Joined: Sat Oct 20, 2007 7:38 pm
Projects: http://bit.ly/2lieZsA
Organization: Sakevisual, Apple Cider, Mystery Parfait
Tumblr: DejiNyucu
Deviantart: DejiNyucu
Location: Chile
Contact:

Re: Some ATL and zorder questions...

#2 Post by Deji »

I got around the yoffset issue by toying with yanchor.
It looks funny, but it works :3

Code: Select all

    transform speak:
            linear .2 yanchor .9
            linear .2 zoom 1.15
    
    transform endspeak:
        parallel:
            linear .2 zoom 1
            linear .2 yanchor .99
        parallel:
            yoffset 100 #all the sprite positions have this offset as well, because they're too tall and to allow the bounce.

    transform left:
        xanchor 0.5
        yalign 1.0
        xpos .2 yoffset 100

    transform right:
        xanchor 0.5
        yalign 1.0
        xpos .75 yoffset 100

    # Little excited jump!        
    transform bounce_up: 
        easeout 0.2 yoffset 70
        easein 0.2 yoffset 100
So what I do is this:

Code: Select all

    show charA at right
    show charB at left
    show charA zorder 3 at speak
    ca "I'm speaking at front!" 
    show charA zorder 0 at endspeak
    show charB zorder 3 at speak
    cb "Now I'm speaking at front and characterA has gone back :)"
    show charB at bounce
    cb "And I can bounce!"
    show charA at bounce
    ca "I can bounce in the back too!"
Image
Tumblr | Twitter
Forever busy :')
When drawing something, anything, USE REFERENCES!! Use your Google-fu!
Don't trust your memory, and don't blindly trust what others teach you either.
Research, observation, analysis, experimentation and practice are the key! (:

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Some ATL and zorder questions...

#3 Post by PyTom »

My answer to this is:

Code: Select all

transform speak:
    linear .05 zoom 1.1

transform nospeak:
    linear .05 zoom 1.0

init python:

    class RaiseImage(object):

        def __init__(self, tag, low=0, high=10, speak=speak, nospeak=nospeak):
            self.tag = tag
            self.low = low
            self.high = high
            self.speak = speak
            self.nospeak = nospeak

        def __call__(self, event, **kwargs):

            if not renpy.showing(self.tag):
                return

            at_list = list(renpy.get_at_list(self.tag))

            if at_list:
                if at_list[-1] is self.nospeak:
                    at_list.pop()
                elif at_list[-1] is self.speak:
                    at_list.pop()

            if event == "begin":
                renpy.show(self.tag, zorder=self.high, at_list=at_list + [ self.speak ])
            elif event == "end":
                renpy.show(self.tag, zorder=self.low, at_list=at_list + [ self.nospeak ])
Use it like:

Code: Select all

define e = Character("Eileen", callback=RaiseImage("eileen"))
define l = Character("Lucy", callback=RaiseImage("lucy"))
Where eileen and lucy are the image tags used by the two characters.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Deji
Cheer Idol; Not Great at Secret Identities
Posts: 1592
Joined: Sat Oct 20, 2007 7:38 pm
Projects: http://bit.ly/2lieZsA
Organization: Sakevisual, Apple Cider, Mystery Parfait
Tumblr: DejiNyucu
Deviantart: DejiNyucu
Location: Chile
Contact:

Re: Some ATL and zorder questions...

#4 Post by Deji »

Thanks a lot! I'm going to give it a try later :D
Image
Tumblr | Twitter
Forever busy :')
When drawing something, anything, USE REFERENCES!! Use your Google-fu!
Don't trust your memory, and don't blindly trust what others teach you either.
Research, observation, analysis, experimentation and practice are the key! (:

User avatar
TsukiWorks
Regular
Posts: 27
Joined: Sat Jun 23, 2018 6:50 am
Projects: The Misunderstood
Deviantart: TsukiWorks
Contact:

Re: Some ATL and zorder questions...

#5 Post by TsukiWorks »

PyTom wrote: Sat Apr 04, 2015 10:34 pm My answer to this is:

Code: Select all

transform speak:
    linear .05 zoom 1.1

transform nospeak:
    linear .05 zoom 1.0

init python:

    class RaiseImage(object):

        def __init__(self, tag, low=0, high=10, speak=speak, nospeak=nospeak):
            self.tag = tag
            self.low = low
            self.high = high
            self.speak = speak
            self.nospeak = nospeak

        def __call__(self, event, **kwargs):

            if not renpy.showing(self.tag):
                return

            at_list = list(renpy.get_at_list(self.tag))

            if at_list:
                if at_list[-1] is self.nospeak:
                    at_list.pop()
                elif at_list[-1] is self.speak:
                    at_list.pop()

            if event == "begin":
                renpy.show(self.tag, zorder=self.high, at_list=at_list + [ self.speak ])
            elif event == "end":
                renpy.show(self.tag, zorder=self.low, at_list=at_list + [ self.nospeak ])
Use it like:

Code: Select all

define e = Character("Eileen", callback=RaiseImage("eileen"))
define l = Character("Lucy", callback=RaiseImage("lucy"))
Where eileen and lucy are the image tags used by the two characters.
Hello! Thanks a lot for this code, it's working fine for me! I have one question though. How can I zoom on a character whenever they speak, when I show different images of them? For example, I have images with different attributes ("chiyori smile", "chiyori normal", "chiyori sad"...)
Thanks in advance!

Post Reply

Who is online

Users browsing this forum: decocloud