TIP: Change Attribute for Images
JGary321
Member Posts: 1,246
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.
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
Danka.
Very helpful! Thanks!
Rebump - Glad I could be of help.
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!
And if I could concatenate Attribute names, that would save me another 500.
It would make my life SO much easier!
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.
any help soon would be great
and make sure the game.HeadCount is selected from the attribute browser and not manually typed in.
YESs... works! seems like it was that i was typing it in not using the attribute browser. huge thx