Page 1 of 1

Side Image Left/Right

Posted: Sat Feb 17, 2018 3:39 am
by wyverngem
I recently converted my side images to LiveComposite() and ConditionSwitch(). My original code used Image() and had an xalign set based on the sprite. Some of my sprites were set to the left and other's to the right. I don't know how to add an xalign to LiveComposite or ConditionSwitch and I realize I need an extra pair of eyes to fix this. This was the old code:

Code: Select all

transform change_transform(old, new):
    contains:
        old
        alpha 1.0
        linear 0.3 alpha 0.0
    contains:
        new
        alpha 0.0
        linear 0.3 alpha 1.0
    
define config.side_image_change_transform = change_transform
    
image side mary_face = ConditionSwitch(
    "rf == 'base'", Image("images/side_mary.png", yalign=1.0, xalign=1.0),
    "rf == 'angry'", Image("images/side_mary angry.png", yalign=1.0, xalign=1.0),
    "rf == 'sad'", Image("images/side_mary sad.png", yalign=1.0, xalign=1.0),
    "rf == None", Image("images/side_side_mary.png", yalign=1.0, xalign=1.0)
    )
The position of the side image was based on the yalign and xalign and when transformed it would only switch places depending on the character speaking. In the new code is there a place to add a position? The transform and the config.side_image_change_transform haven't changed. I don't want to add a xalign to the transform because some sprites need to be on the left and the other's on the right. Current code of side image used.

Code: Select all

image side erin_small = LiveComposite(
    (617, 653),
    (0, 0), "ebase.png",
    (135, 241),
        ConditionSwitch(
            "efe == 'norm'", ConditionSwitch("str(ep) == 'type1'", "eyes type1","str(ep) == 'type2'","eyes type2","str(ep) == 'type3'", "eyes type3"),
            "efe == 'glance'", ConditionSwitch("str(ep) == 'type1'", "eyes type1_glance","str(ep) == 'type2'","eyes type2_glance","str(ep) == 'type3'", "eyes type3_glance"),
            "efe == 'nar'", ConditionSwitch("str(ep) == 'type1'", "eyes type1_nar","str(ep) == 'type2'","eyes type2_nar","str(ep) == 'type3'", "eyes type3_nar"),
            "efe == 'sur'", ConditionSwitch("str(ep) == 'type1'", "eyes type1_sur","str(ep) == 'type2'","eyes type2_sur","str(ep) == 'type3'", "eyes type3_sur")
        ),
    (179, 360), ConditionSwitch("efm == 'close'", "images/mouth.png","efm == 'part'", "images/mouth-part.png","efm == 'open'", "images/mouth-yell.png"),
    (113, 203), ConditionSwitch("efb == 'norm'", "images/b.png","efb == 'nar'", "images/b-frown.png","efb == 'huh'", "images/b-huh.png","efb == 'sad'", "images/b-sad.png","efb == 'sur'", "images/b-sur.png"))

Re: Side Image Left/Right

Posted: Sat Feb 17, 2018 4:59 am
by Andredron
Try the property in the coordinates of the person. As an example, the CTC

Code: Select all

define ectcf = Character(_('Eileen'), color="#c8ffc8", ctc=anim.Filmstrip("sakura.png", (20, 20), (2, 1), .30, xpos=760, ypos=560, xanchor=0, yanchor=0), ctc_position="fixed")

Re: Side Image Left/Right

Posted: Sat Feb 17, 2018 9:05 pm
by wyverngem
Not working for me.

I've tried writing out the code in an Image() fully and it returns an error that it expects a graphic. The other way I thought to write from you example was this:

Code: Select all

define e = Character("Erin", image=Image(erin_small,  yalign=1.0, xalign=1.0))
However, it returns the error: NameError: name 'eir_small' is not defined.

If I put erin_small in quotes there's no error, but the image isn't displayed at all.

Re: Side Image Left/Right

Posted: Mon Feb 19, 2018 3:12 pm
by IrinaLazareva
xalign of SideImage is registered in screen say (screens.rpy file).
Look on lines:

Code: Select all

screen say(who, what):

    #<body of the screen>#

    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0        <<< == this line
You can to create a condition, for example by name of Character():

Code: Select all

define e = Character("Erin", image='erin_small')

Code: Select all

screen say(who, what):
    #<body of the screen>#

    if not renpy.variant("small"):
    
        if who=='Erin':
            add SideImage() xalign 1.0 yalign 1.0
        elif who=='John':
            add SideImage() xalign 0.0 yalign 1.0   
If there is a lot of characters, it is possible to create the list of them. 4 example:

Code: Select all

define list_of_left = ['John', 'James', 'Mary']
and then

Code: Select all

screen say(who, what):
    #<body of the screen>#

        if who in list_of_left:
            add SideImage() xalign 0.0 yalign 1.0
        else:
            add SideImage() xalign 1.0 yalign 1.0   

Re: Side Image Left/Right

Posted: Sat Feb 24, 2018 2:50 am
by wyverngem
I actually ended up changing the beginning from this

Code: Select all

image side eir_small = LiveComposite(
To

Code: Select all

image side eir_small:
    xalign 1.0 yalign 1.0
    LiveComposite(#continued with long code here
And it ended up working perfectly. I didn't need to mess with my screens. Just changed the line to take away the xalign and yalign from the "add SideImage()" and it worked again.

Re: Side Image Left/Right

Posted: Mon Oct 24, 2022 7:26 am
by tohtamish
Guys that doesn't work and I don't know why... P is the short name of char which is supposed to be at the right.

Code: Select all

    if not renpy.variant("small"):
        if who == "p":
            add SideImage() xalign 0.8 yalign 0.85
        else:
            add SideImage() xalign 0.06 yalign 0.85

(found this topic in google and decided to up it here such way)

Re: Side Image Left/Right

Posted: Mon Oct 24, 2022 3:02 pm
by Alex
tohtamish wrote:
Mon Oct 24, 2022 7:26 am
Guys that doesn't work and I don't know why... P is the short name of char which is supposed to be at the right.

Code: Select all

    if not renpy.variant("small"):
        if who == "p":
            add SideImage() xalign 0.8 yalign 0.85
        else:
            add SideImage() xalign 0.06 yalign 0.85

(found this topic in google and decided to up it here such way)
If you have

Code: Select all

define p = Character('player')
then try

Code: Select all

    if not renpy.variant("small"):
        if who == "player":

Re: Side Image Left/Right

Posted: Tue Oct 25, 2022 9:33 am
by tohtamish
Alex wrote:
Mon Oct 24, 2022 3:02 pm
tohtamish wrote:
Mon Oct 24, 2022 7:26 am
Guys that doesn't work and I don't know why... P is the short name of char which is supposed to be at the right.

Code: Select all

    if not renpy.variant("small"):
        if who == "p":
            add SideImage() xalign 0.8 yalign 0.85
        else:
            add SideImage() xalign 0.06 yalign 0.85

(found this topic in google and decided to up it here such way)
If you have

Code: Select all

define p = Character('player')
then try

Code: Select all

    if not renpy.variant("small"):
        if who == "player":
Man thanks a lot, it helped! By the way name of character itself is in not-english letters, russian cyrilic, I have to check it on only english PCs then or to chang name somehow to english common names like Anna, Aleksander, etc...