TIP: Change Attribute for Images

JGary321JGary321 Member Posts: 1,246
edited November -1 in Working with GS (Mac)
I'm sure a lot of people know this, but you don't have to use Change Image to change an image.

Example of a HUGE time saver.

I have 5 different units to keep track of & I wanted to display the unit level without using the built in fonts. I made all my graphics & imported into GS.

So, normal ideology would state to do something like this....

If Hero LVL = 1
Change Image to Lvl 1

If Hero LVL = 2
Change Image to Lvl 2

I have 5 units, so this would take LOTS of time.

I am already keeping track of each units level in a game.attribute, so this is what I did.

(my image files are name a1.png, a2.png, a3.png, etc..)
If Hero = selected
Change Attribute to 'a'..game.Hero LVL..'.png'
(translation: Change Attribute to a1.png)(or whatever level the hero is)

As you can tell this was a HUGE time/space saver. Just wanted to make sure everyone knew that images can be changed by Expression by using the change attribute behavior instead of change image. Especially since it's not obvious.

Comments

  • BeyondtheTechBeyondtheTech Member Posts: 809
    This is an incredible tip, I know exactly where this will come in handy!

    Danka.
  • stanimationstanimation Member Posts: 406
    Very nice tip. Thanks!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Awesome! That can easily be applied to my custom score fonts demo...

    Very helpful! Thanks!
  • rebumprebump Member Posts: 1,058
    JGary: That is a mechanism that I use extensively in many of the things I do programming-wise outside of GS. I never really thought GS was able to handle that due to the way expressions are built in the expression builder window. I never really tested it out. Thanks for testing and pointing out a mechanism that can come in handy in various places such as in your demonstration above. What is that old adage about "assume"!? ;-) Sweetness!
  • JGary321JGary321 Member Posts: 1,246
    FMG - Yea I am currently using it for my custom fonts as well =) Makes it ALOT easier.

    Rebump - Glad I could be of help.
  • SlowboySlowboy Member, PRO Posts: 329
    Wow! Thanks Gary! This is going to save me approximately 5.2 Hours! I actually worked that out with a calculator.
    I've just posted a response to Venon about changing images, and told them how to do it the long way! I'd best get back there and point him over here!
    Seriously though, this is the kind of information that should find it's way onto a sticky somewhere - I can see this method quickly becoming 'the norm' and something that new users would (should) learn very early on, rather than stumbling across it months down the line!
    Apologies to Devs if this info is already somewhere permanent, but if it isn't, please put it somewhere!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    If they would let me concatenate Scene names like this, I could cut down on 300 extra Rules (literally!)

    And if I could concatenate Attribute names, that would save me another 500.
    It would make my life SO much easier!
  • RolentoRolento Member Posts: 9
    I've done what the top post has done and it dosnt work...

    i have my actor with

    Change Attribute self.Image to 'h'..game.HeadCount..'.png'

    and my image files loaded into GS are h1.png, h2.png, h3.png, etc

    with this i am getting a missing image :( tell me im doing something wrong.
  • RolentoRolento Member Posts: 9
    I cant move on with this project due to this :(

    any help soon would be great
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    try "h"..game.HeadCount..".png"

    and make sure the game.HeadCount is selected from the attribute browser and not manually typed in.
  • RolentoRolento Member Posts: 9
    ok awesome thanks. life saver ^_^

    YESs... works! seems like it was that i was typing it in not using the attribute browser. huge thx
Sign In or Register to comment.