Change actor image based on scene

jon2sjon2s Member Posts: 40
edited November -1 in Working with GS (Mac)
I have 15 different actors in a scene that all have the same image set in the actor. When I go to scene 2, I don't want to have to edit each instance to change the image or have to duplicate the actors for each scene or create a huge if statement for each possible scene. Is there a way that you can create a text variable or something so you can specify it on a single actor in the scene and change the image based off that variable?

i.e. variable imagename = image.png
in each actor if current_image_name != imagename
change image to imagename

Comments

  • jmp909jmp909 Member Posts: 73
    in each scene set an attribute

    game.sceneNum = 1 etc

    in your actor prototype set

    rule: change image to "sceneactor" + game.sceneNum + ".png"

    i *think* that should change actors on scene 1 to sceneactor1.png, actors on scene2 to sceneactor2.png etc

    j.
  • quantumsheepquantumsheep Member Posts: 8,188
    Yep - in your actor it's just a bunch of:

    IF sceneNum = 1
    Then change image to image1

    IF sceneNum=2
    Then change image to image2

    etc...

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • millerbrother1millerbrother1 Member Posts: 108
    Hey QS,

    Can't you do this via the ChangeAttribute self.Image. For example if you wanted a variety of images to be used based on which scene was loaded (Level-1.png, Level-2.png, etc.) couldn't you use logic similar to the following?

    Change Attribute self.Image to "Level-"+"game.CurrentLevel"+".png"

    It isn't working for me, but I'm curious if you know a way. This would keep you from having to create a bunch of rules in the Actor.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    millerbrother1 said:
    Change Attribute self.Image to "Level-"+"game.CurrentLevel"+".png"

    It isn't working for me, but I'm curious if you know a way. This would keep you from having to create a bunch of rules in the Actor.

    the expression needs to use ".." instead of "+" and attributes don't need the double quotes.
    So

    "Level-"..game.CurrentLevel..".png"
Sign In or Register to comment.