Side Image Left/Right

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
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Side Image Left/Right

#1 Post 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"))

User avatar
Andredron
Miko-Class Veteran
Posts: 714
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Side Image Left/Right

#2 Post 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")

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Side Image Left/Right

#3 Post 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.

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Side Image Left/Right

#4 Post 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   

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Side Image Left/Right

#5 Post 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.

User avatar
tohtamish
Regular
Posts: 65
Joined: Thu Apr 29, 2010 4:56 am
Contact:

Re: Side Image Left/Right

#6 Post 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)

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Side Image Left/Right

#7 Post 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":

User avatar
tohtamish
Regular
Posts: 65
Joined: Thu Apr 29, 2010 4:56 am
Contact:

Re: Side Image Left/Right

#8 Post 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...

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot