Changing a character's associated image in the middle of the game

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
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Changing a character's associated image in the middle of the game

#1 Post by trooper6 »

Quick question.

Lets say you have two images.

image mcy = "images/mc_young.png"
and
image mco = "images/mc_old.png"

for example--but let's say these are actually really complex layered images with lots of images tags rather than just simple images.

And let's say that you have a character where halfway through the game you want to switch from layered image to another.

Sure, one way to do it would be to make two different characters, like so:

define mcy = Character("Young Lizzie", image="mcy")
define mcp = Character("Elizabeth", image="mco")

But, is there a way to have one character and just change the associated image halfway through the game?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

mikolajspy
Regular
Posts: 169
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Too many, check signature
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Re: Changing a character's associated image in the middle of the game

#2 Post by mikolajspy »

I did something similar on old Ren'Py version, but hopefully it will still work with new layered image system. The old and good ConditionSwitch!
It might be not 100% correct, but something like:

Code: Select all

define mc = Character("Elizabeth", image="mc")
default mca = 0 #Main Character Age, just change variable to 1 in mid-game.
image mc:
    ConditionSwitch(
        "mca == 0", "mcy",
        "mca == 1", "mco",
        )
### You need to declare "mcy" and "mco" images somewhere else

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Changing a character's associated image in the middle of the game

#3 Post by trooper6 »

I tried it out...but non the of the image tags work if you use a condition switch, sadly.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: No registered users