How modify alpha value?

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
MarFazzo
Newbie
Posts: 7
Joined: Tue Jan 26, 2016 10:44 am
Contact:

How modify alpha value?

#1 Post by MarFazzo » Tue Jan 26, 2016 10:48 am

Hi all, i am new to Ren'Py. I wrote this code:

Code: Select all

image image1= im.Scale("image1.png",150,150)
init:
     $ esubtitle = Character(None, what_size=34, what_outlines=[(1, "#fff", 0, 0)], what_text_align=0, window_background="#f7b916", window_yminimum=150, window_right_padding=180, window_xfill=True, window_xalign=0.0)

# The game starts here.
label start:

     scene black
     show image1 at Position(xpos=0.995, xanchor=1.0, ypos=0.80, yanchor=0.0) as image1
     esubtitle "My first test"

     return
but the "image1" is displayed under the "esubtitle". How can I modify the alpha value of "image1"?

Thanks in advance

User avatar
Iylae
Regular
Posts: 73
Joined: Sat Jan 09, 2016 6:57 am
Location: Cornwall, UK
Contact:

Re: How modify alpha value?

#2 Post by Iylae » Tue Jan 26, 2016 10:54 am

There's an alpha variable when showing images using ATL
alpha
Type: float
Default: 1.0
This controls the opacity of the displayable.

The alpha transform is applied to each image comprising the child of the transform independently. This can lead to unexpected results when the children overlap, such as as seeing a character through clothing. The Flatten() displayable can help with these problems.
Image
  If we are what we repeatedly do, then good coding is not an act, but a habit

MarFazzo
Newbie
Posts: 7
Joined: Tue Jan 26, 2016 10:44 am
Contact:

Re: How modify alpha value?

#3 Post by MarFazzo » Tue Jan 26, 2016 11:02 am

I tried but "alpha" wasn't what i was searching for. In my example i want to overlap an image to the "character text window". I tried all but the caracter text window is ever above the image. How can i do this?

MarFazzo
Newbie
Posts: 7
Joined: Tue Jan 26, 2016 10:44 am
Contact:

Re: How modify alpha value?

#4 Post by MarFazzo » Tue Jan 26, 2016 11:29 am

I tried but "alpha" wasn't what i was searching for. In my example i want to overlap an image to the "character text window". I tried all but the caracter text window is ever above the image. How can i do this?

User avatar
chocojax
Miko-Class Veteran
Posts: 702
Joined: Sun Oct 25, 2009 11:27 am
Completed: http://art.jphi.me/projects
Projects: Umbra, Familiarity, Maleficent Justice
Organization: spaceNote
Tumblr: chocojax
Github: jenniferphi
Location: California
Contact:

Re: How modify alpha value?

#5 Post by chocojax » Tue Jan 26, 2016 11:59 am

So, you want to put image1.png over the text box? Go into screens.rpy and add it to the screen say. You'll want something like:

Code: Select all

screen say(who, what, side_image=None, two_window=False):

    # 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 0.0 yalign 1.0

    add "image1.png" #other properties here

    # Use the quick menu.
    use quick_menu

MarFazzo
Newbie
Posts: 7
Joined: Tue Jan 26, 2016 10:44 am
Contact:

Re: How modify alpha value?

#6 Post by MarFazzo » Tue Jan 26, 2016 12:06 pm

And what can I do if the image is different in different scenes?

User avatar
chocojax
Miko-Class Veteran
Posts: 702
Joined: Sun Oct 25, 2009 11:27 am
Completed: http://art.jphi.me/projects
Projects: Umbra, Familiarity, Maleficent Justice
Organization: spaceNote
Tumblr: chocojax
Github: jenniferphi
Location: California
Contact:

Re: How modify alpha value?

#7 Post by chocojax » Tue Jan 26, 2016 12:35 pm

Maybe you could use side images instead (http://www.renpy.org/doc/html/side_image.html) to show different overlaying images at different times?

Or, you could use variables and if/else statements in the screen to change it. (Not sure if this would work though, would test but I'm not able to use a computer at the moment.)

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How modify alpha value?

#8 Post by philat » Tue Jan 26, 2016 10:23 pm


Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]