Referencing an image within an image

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
Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Referencing an image within an image

#1 Post by Onishion » Thu Jun 09, 2016 6:04 pm

Ok, basically what I'm trying to do is build an alphamask that makes use of an image that is part of a larger image structure. I use the line "AlphaMask("ImagetobeMasked", "MaskingImage")", and that works fine so long as "ImagetobeMasked" and "MaskingImage" are each their own distinct images, but what I'd really like to do is have MaskingImage be a part of a live composite, like:

Code: Select all

image TestLC = LiveComposite(                                                                     
    (100, 100),    
    (0, 0), ConditionSwitch(     
            "Var == 3", "MaskingImage",          
            "True", "MaskingImage2",           
            ),
    )
and then to be able to reference that I want to use the MaskingImage that is inside the TestLC as the mask, something along the lines of "TestLC:MaskingImage" to differentiate it from any other instance of that image. Is this at all possible? The point for it is that I want an instance of the image to be animated as a child to other images and animations, and for the mask to adopt all that animation automatically.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Referencing an image within an image

#2 Post by PyTom » Fri Jun 10, 2016 12:26 am

i believe the code you gave should work.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
vollschauer
Veteran
Posts: 231
Joined: Sun Oct 11, 2015 9:38 am
Github: vollschauer
Contact:

Re: Referencing an image within an image

#3 Post by vollschauer » Fri Jun 10, 2016 2:20 am

I always define my ConditionSwitch images first and then build the LiveComposite ones...

Code: Select all

image MaskingImage = ConditionSwitch(  
    "Var == 3", "path/MaskingImage.png",         
    "True", "path/MaskingImage2.png")

image TestLC = LiveComposite(                                                                     
    (100, 100),   
    (0, 0), MaskingImage)
..something like that.

Post Reply

Who is online

Users browsing this forum: Alex, nyeowmi