Changing game images based on attributes

millerbrother1millerbrother1 Member Posts: 108
edited November -1 in Working with GS (Mac)
Okay, I haven't been getting any response by posting my question to related discussions that were already started on this subject. So, I figured I'd start a new one in case it has a better shot at catching someone's attention. :-)

Here's the sitch:

I have a real number game level attribute named "CurrentLevel" that tracks the current scene being played (1,2,3, etc). At the start of each new level, I have an actor with a graphic that pops up for a few seconds to identify to the player which level number they are about to start.

I was curious if I could make this image change based on the number logged in the game attribute. Something like this is what I had in mind.

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

My thought was that this would set the image to "Level-1.png" or "Level-2.png" depending on the CurrentLevel being played. It seems right in theory but in actuality it doesn't change the image. Is there a better approach to accomplishing this without creating a rule for every level?

I'm trying to avoid the IF game.CurrentLevel is 1 THEN change Image to "Level-1.png" process, because it becomes tedious to do it for 50+ levels.

Any help would be appreciated.

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    First, and it doesn't really matter, but currentLevel should be an integer... Real numbers are for when you need decimal places, i.e: 1.25, 4.56, etc..

    And you can do what you want, it just needs to be written like this:

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

    Use double periods instead of plus signs.
  • millerbrother1millerbrother1 Member Posts: 108
    Never knew about the .. Thanks FMG, that fixed it!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Cool! Glad you got it working!

    Yeah, that is called concatenation. My latest game depends entirely on it!
Sign In or Register to comment.