Joining Variables
Damien
Member Posts: 8
Need to know if this is possible. I want to switch images based upon a dynamic number, ie, number may change from 1-10. The images are eg. image1.png ... image10.png. What I am finding is if I have 3 global variables : pre="image", cImg=(1-10), post=".png" I cant join them together.
ie, display text = game.pre + game.cImg + game.post ==> "image3.png"
Just to clarify, its the joining of strings that doesn't work. Am I correct in this or am I being too much of a programmer?
Cheers,
ie, display text = game.pre + game.cImg + game.post ==> "image3.png"
Just to clarify, its the joining of strings that doesn't work. Am I correct in this or am I being too much of a programmer?
Cheers,
Comments
So you have the global variable 'Lives' which is set at 10.
If your main actor collides with another then the variable 'Lives' is put down by one.
So in the health bar, I have the rules:
If Lives = 10, then change image to 10.png
If Lives = 9, then change image to 9.png
and so on.
Is that the kind of thing you're on about? Or have I missed the point entirely?
Cheers,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
But for now, I'll use 32 rules. lol.
Thanks,
Although I wouldn't suggest that as a permanent solution.
I'm loving this product so far. I just downloaded it this afternoon and already have a prototype up an running. I'm now leaning towards using gamesalad instead of itorque (even though I already own and know tgb).
QS, I'd use this for your health bar animation, save you 9 rules.
Thanks CM.
For example, a game I've been working on makes use of hand-drawn, animated numbers for displaying each digit of a score. Originally this took ten rules per actor, but I was able to cut that down to one. All I did was rename my images using numbers, for example "01.png" = the digit 0, frame 1 and "93.png" = the digit 9, frame 3, and then create a single rule per actor like this:
Constrain Attribute [ self.Image ] to [ self.Value..game.CurrentFrame..game.ImageSuffix ]
self.Value is the integer to be displayed;
game.CurrentFrame is an integer that rotates from 1-3 to create the 3-frame animation;
game.ImageSuffix is simply the text ".png"
Sounds good to me - will revisit all my health bars at some point - cheers!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io