Page 1 of 1

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

Posted: Sat Apr 04, 2015 11:17 am
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

Re: Some ATL and zorder questions...

Posted: Sat Apr 04, 2015 6:30 pm
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!"

Re: Some ATL and zorder questions...

Posted: Sat Apr 04, 2015 10:34 pm
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.

Re: Some ATL and zorder questions...

Posted: Sat Apr 04, 2015 10:40 pm
by Deji
Thanks a lot! I'm going to give it a try later :D

Re: Some ATL and zorder questions...

Posted: Sat Oct 13, 2018 3:26 am
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!