Having side image position change depending on the character

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
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Having side image position change depending on the character

#1 Post by AERenoir »

I have two characters with side images. I want character A's image to be aligned to the left while character B is aligned to the right. How do I do that?

In the old wiki code, I can declare the xalign in the character declare code, but now that the side image system changed, it doesn't work anymore.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: Having side image position change depending on the chara

#2 Post by AERenoir »

*bump*

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

Re: Having side image position change depending on the chara

#3 Post by Alex »

You need to modify say screen a bit - add a variable for side image position, then you'll be able to set its value for different characters, like

Code: Select all

screen say:

    # Defaults for side_image and two_window
    default side_image = None
    default two_window = False
    default side_xalign = 0.0   # default values, so you don't need to change all the characters 
    default side_yalign = 1.0

    # Decide if we want to use the one-window or two-window variant.
    if not two_window:

        # The one window variant.
        window:
            id "window"

            has vbox:
                style "say_vbox"

            if who:
                text who id "who"

            text what id "what"

    else:

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:
                window:
                    style "say_who_window"

                    text who:
                        id "who"

            window:
                id "window"

                has vbox:
                    style "say_vbox"

                text what id "what"

    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign side_xalign yalign side_yalign #xalign 0.0 yalign 1.0

    # Use the quick menu.
    use quick_menu

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8", image="eileen", show_side_xalign=1.0)
image side eileen = "eileen_side.png"

# The game starts here.
label start:

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"
(while character declaration, custom variables must be prefixed with extra "show_" in their names).

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Having side image position change depending on the chara

#4 Post by DragoonHP »

Another way to do this is:

Code: Select all

define eLeft = Character('Eileen', color="#c8ffc8", show_side_image = Image("e.png", xalign = 0.0, yalign = 1.0) )
define eRight = Character('Eileen', color="#c8ffc8", show_side_image = Image("e.png", xalign = 1.0, yalign = 1.0) )

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: Having side image position change depending on the chara

#5 Post by AERenoir »

Alex wrote:You need to modify say screen a bit - add a variable for side image position, then you'll be able to set its value for different characters, like

Code: Select all

screen say:

    # Defaults for side_image and two_window
    default side_image = None
    default two_window = False
    default side_xalign = 0.0   # default values, so you don't need to change all the characters 
    default side_yalign = 1.0

    # Decide if we want to use the one-window or two-window variant.
    if not two_window:

        # The one window variant.
        window:
            id "window"

            has vbox:
                style "say_vbox"

            if who:
                text who id "who"

            text what id "what"

    else:

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:
                window:
                    style "say_who_window"

                    text who:
                        id "who"

            window:
                id "window"

                has vbox:
                    style "say_vbox"

                text what id "what"

    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign side_xalign yalign side_yalign #xalign 0.0 yalign 1.0

    # Use the quick menu.
    use quick_menu

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8", image="eileen", show_side_xalign=1.0)
image side eileen = "eileen_side.png"

# The game starts here.
label start:

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"
(while character declaration, custom variables must be prefixed with extra "show_" in their names).

Thanks, Alex!!
DragoonHP wrote:Another way to do this is:

Code: Select all

define eLeft = Character('Eileen', color="#c8ffc8", show_side_image = Image("e.png", xalign = 0.0, yalign = 1.0) )
define eRight = Character('Eileen', color="#c8ffc8", show_side_image = Image("e.png", xalign = 1.0, yalign = 1.0) )
That is the old code that I said don't work too well for what I need.

User avatar
balldancing
Regular
Posts: 65
Joined: Tue Sep 03, 2013 9:32 am
Location: milan
Contact:

Re: Having side image position change depending on the chara

#6 Post by balldancing »

Alex wrote:You need to modify say screen a bit - add a variable for side image position, then you'll be able to set its value for different characters, like

Code: Select all

screen say:

    # Defaults for side_image and two_window
    default side_image = None
    default two_window = False
    default side_xalign = 0.0   # default values, so you don't need to change all the characters 
    default side_yalign = 1.0

    # Decide if we want to use the one-window or two-window variant.
    if not two_window:

        # The one window variant.
        window:
            id "window"

            has vbox:
                style "say_vbox"

            if who:
                text who id "who"

            text what id "what"

    else:

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:
                window:
                    style "say_who_window"

                    text who:
                        id "who"

            window:
                id "window"

                has vbox:
                    style "say_vbox"

                text what id "what"

    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign side_xalign yalign side_yalign #xalign 0.0 yalign 1.0

    # Use the quick menu.
    use quick_menu

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8", image="eileen", show_side_xalign=1.0)
image side eileen = "eileen_side.png"

# The game starts here.
label start:

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"
(while character declaration, custom variables must be prefixed with extra "show_" in their names).
hi there!! this is perfect~ just one problem :s after adding this, i lost my namebox and show_two_window=True isn't working anymore. any ideas?
Image
I offer proofreading and editing services~

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

Re: Having side image position change depending on the chara

#7 Post by Alex »

That's strange, 'cause this script working fine for me

Code: Select all

# Declare characters used by this game.
define narrator = Character(" ", show_two_window=True)    # if you need the namebox for narrator too
define e = Character('Eileen', color="#c8ffc8", image="eileen", show_side_xalign=1.0, show_two_window=True)

User avatar
minyan
Miko-Class Veteran
Posts: 630
Joined: Tue Feb 10, 2015 3:59 pm
Completed: Trial By Fire, Heartbaked, Ellaria, Plain, This My Soul, The Pretenders Guild
Projects: Arena Circus
Tumblr: minyanstudios
itch: harlevin
Contact:

Re: Having side image position change depending on the character

#8 Post by minyan »

Are there any recent updates on this code? None of these options are working for me.
ImageImage

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot]