I'm just adding the missing apostrophes for future reference.
Edit: 6/2/2012. Another newbie edit. If you use folders, the original cookbook suggests "/folder/image.png". There is no need for that first slash!!! Removed that first slash from the comment below.
-----------------------------------------
Showing layered sprites with different emotions
Have you ever wanted to make a layered image but you didn't want to declare separate statements for each one? Are you tired of using "show eileen happy at center with dissolve"?
Then this is for you! Welcome to the world of LiveComposite and dynamic displayables using ConditionSwitch! You'll only need to declare something like "$ Janetmood = mad" to change the emotion on her face or the pose and any number of fun things.
Code: Select all
#Put this in your init section!
init:
#This declares a conditional image with a LiveComposite inside of it
image eileen = ConditionSwitch(
"e_face == 'happy'", LiveComposite(
#If she's happy, call the LiveComposite
(375, 480),
(0, 0), "e.png",
#This is the size of the sprite in widthxheight of pixels
#I'm telling it not to move e.png but use the base dimensions and
#the path to e.png. If I had it in a folder, it would be
#"foldername/imagename.format"
#This is probably the "base" image or body.
(94, 66), "e_happy.png",
#This is 94 pixels to the right and 66 pixels down, if I remember correctly
#This is the alternate face layer, which is put on top of the stack.
#So the order goes bottom to top when you're listing images.
),
"e_face == 'sad'", LiveComposite(
(375, 480),
(0, 0), "e.png",
(94, 66), "e_sad.png",
#Don't forget your commas at the end here
),
"e_face == None", "e.png")
#If it's not set to anything, the neutral base "e.png" displays
#Be sure to close your parentheses carefully
label start:
#This is how you call it during the game itself
show eileen
#This shows the LiveComposite "e.png" when e_face == None. We haven't changed it yet.
e "I'm neutral."
#Now we change the variable to happy.
$ e_face = "happy"
e "Now sprite is happy!"
#You can also declare ConditionSwitches in Character statements to
#change the side image.