From my rough understanding of reading the documentation on Layered Images, everything that you can achieve with Composite you can also do there for this purpose.
Strictly speaking, yes, but layered images goes way further than the
Composite
displayable. It's more a way to define complex images that initially needed both
Composite
and
You must be registered to see the links
displayable to be describe. What can now be wrote like this :
Code:
layeredimage eileen:
always:
"character/eileen/body.png"
group outfit:
attribute classy:
"character/eileen/dress_classy.png"
attribute slutty:
"character/eileen/dress_slutty.png"
Initially had to be wrote like that :
Code:
image eileenOutfit = ConditionSwitch(
"eileenDress == 'classy'", "character/eileen/dress_classy.png",
"eileenDress == 'slutty'", "character/eileen/dress_slutty.png" )
image eileen = Composite(
(100,100),
(0,0), "character/eileen/body.png",
(0,0), "eilenOutfit" )
Note that the doc example don't show it explicitly, but the
if
used inside the definition of a layered image follow the effective structure of an
if
block, and isn't limited to Boolean values. This permit to have layered images following the example for
ConditionSwitch
:
Code:
layeredimages eileen:
always:
"character/eileen/body.png"
group outfit:
attribute classy:
"character/eileen/dress_classy.png"
attribute slutty:
"character/eileen/dress_slutty.png"
if eileenBeer > 4:
"character/eileen/face_drunk.png"
elif eileenBeer > 2:
"character/eileen/face_tipsy.png"
else:
"character/eileen/face.png"
And finally, layered images are created dynamically, which isn't the case of
Composite
one. This imply that you can also have text interpolation inside the definition of a layered image, which can be useful.
Firstly because the layered images syntax is relatively limited. By example, you can have
if
structures, but you can't put a
group
nor an
attribute
in them, nor have the
if
inside a group. Therefore, if you want the character to have a regular body and a tattooed one, while possibly be tanned or not, you would need this :
Code:
layeredimages eileen:
group body:
attribute tattooTan:
"character/eileen/body_tattoo_tan.png"
attribute tattoo:
"character/eileen/body.png"
attribute Tan:
"character/eileen/body.png"
group outfit:
attribute classy:
"character/eileen/dress_classy.png"
attribute slutty:
"character/eileen/dress_slutty.png"
Which start to add a lot since now you'll have to write this
show eileen tattooTan classsy
to display the image. With all the other group you can possible have added to it.
Secondly because in case like this one, the variation is intended to be present in more than one image, and to depend of the character choice. Therefore, you have to deal with the fact that the character have or not a tattoo :
Code:
if eileenTattoo is True:
show eileen tattooTan classy
else:
show eileen tan classy
But with interpolation, you can reduce the size of each image name, while getting ride of the need of the test :
Code:
layeredimages eileen:
always:
"character/eileen/body[isTattooed][hasTan].png"
group outfit:
attribute classy:
"character/eileen/dress_classy.png"
attribute slutty:
"character/eileen/dress_slutty.png"
default isTattooed = ""
default hasTan = ""
The image for the body will depend of the value of
isTattooed
and
hasTan
. By default their value are empty, and the body will be "character/eileen/body.png". Then later you can have this :
Python:
menu:
"Ask her to have a tattoo ?"
"no":
pass
# The image will stay
# charactere/eileen/body.png"
"no, but some tan would be good":
$ hasTan = "_tan"
# Now the image displayed will be
# character/eileen/body_tan.png"
"yes":
$ isTattooed = "_tattoo"
# Now the image displayed will be
# character/eileen/body_tatoo.png"
"yes, and she need some tan on top of this":
$ isTattooed = "_tattoo"
$ hasTan = "_tan"
# Now the image displayed will be
# character/eileen/body_tatoo_tan.png"
And you'll not have to test this later in the game, when you'll display the image, the computation will be automatically done, and the right body will be displayed, whatever the effective value of the two variables.
You can use the same thing to have variation regarding the tan :
Python:
menu:
"Do you want her to have tan lines ?"
"Yes":
$ hasTan = "_tanlines"
# Now the image displayed will be
# charactere/eileen/body_tanlines.png"
"Yes, but she'll tan topless":
$ hasTan = "_tanhalf"
# Now the image displayed will be
# character/eileen/body_tanhalf.png"
"No, she'll tan on the nude":
$ hasTan = "_tannolines"
# Now the image displayed will be
# character/eileen/body_tannolines.png"
"I don't even want her to tan !":
pass
# The image will stay
# character/eileen/body.png"
Am I correct? I think I noticed a noticeable delay when I show the Composite consisting of multiple images and since I did not do much of a work, it should be easy enough to switch everything to Layered.
If there's a delay with
Composite
, there will probably be one with layered images :
-
Composite
displayables are pre-proceeded when the displayable is created, then when displayed, the images are loaded and displayed one on top of the others.
- Layered images are proceeded each time the image is displayed, then the images are loaded and displayed on top of the others, and the whole thing is refreshed at least after each interaction.
Therefore, layered images are slower than
Composite
displayable.
[...] so I can get as much performance and small game as possible.
This let me puzzled. Ren'py can be slow on old computer and tablet/phone with small amount of RAM, but even in those case it should be really sensible with images if they are correctly defined and not oversized. It's only with movies, and animated images, that it can be effectively percieved.
From my point of view, the performance issue can't be solved on Ren'py side, but on yours.