I've gotten my goal to work so far, but I was wondering if there was a better/cleaner way to do the following.
I have 3 character portraits. I put them each on a separate layer, like so:
Layer sally: spriteSally
Layer jake: spriteJake
Layer kelly: spriteKelly
All layers are set to 0 opacity at the start. I have a variable that gets a value from an XML file in order to determine which portrait to show at a time. For example, if my XML value says "sally", I set up events to make that layer go to 100% opacity, and all others to 0%. When "jake" pops up in the XML, that layer is set to 100%, and the others to 0%. So basically, when I want a certain character to show up on the screen, they will, while any others disappear. Thanks!
However, if I have say 10 portraits, I would need 10 layers (one for each). I can make it work, but the code just gets really long and repetitive (since I have to set each individual layer to 0 or 100% each time). Is there a better way to do this? Ideally I'd like to have all the sprites on 1 layer, and show/hide each dynamically instead of typing each one out in an event every time.
EDIT: Forgot to mention that each sprite has animations with it (like smile, laugh, etc.). I thought I could make one sprite that holds *all* portraits/animations for every character, but is that ok design?