Using Change Image behaviour frequently
Cap
Member Posts: 225
Hi,
at the moment I'm frequently changing the image from an enemy actor every few seconds. The points for destroying this enemy actor depends on the image that is set. This seems to work.
So when the enemy gets hit I use;
if self.image contains "image1"
game.points = game.points +100
if self.image contains "image2"
game.points = game.points +200
etc
Any doubts or suggestions?
Thanks.
at the moment I'm frequently changing the image from an enemy actor every few seconds. The points for destroying this enemy actor depends on the image that is set. This seems to work.
So when the enemy gets hit I use;
if self.image contains "image1"
game.points = game.points +100
if self.image contains "image2"
game.points = game.points +200
etc
Any doubts or suggestions?
Thanks.
Comments
Maybe this isn't what you had in mind, but that's my suggestion. I suppose it wouldn't work if you're randomly changing the image in a repeating timer; in that case the game wouldn't know which image was associated with which point value, and you'd have to rely on the if>then series to determine that "small=100", "medium=200", "large=500", or whatever you're doing.
Best of luck,
Brent
thanks for your answer!
It's like that: at the moment I have four different enemies with four different point values. But instead of creating four different actors, I created just one and put this one actor eight or ten times in my scene (as often as I need it). The image of this enemy actor is chosen randomly, and until now if I hit an enemy I just check what image this enemy actor has to get the appropriate point value. I thought that would be more efficient than creating different actors.
As long as we can't use arrays, we have to be inventive. :-)
What do you think of that? I'll check if I can use your suggestion, thanks a lot.
if I'm wrong, it probably would be hard to add an integer attribute and change it to the number associated with the image selected. then you can use that integer as a multiplier for your scoring system:
`
Rule: When enemy gets hit: (no checking for image type here!)
-- change game.points to game.points+(self.enemyID*100)
`
this saves you at least one rule/condition for every possible enemy type...
well, that was a neat idea!
It's like you said, I randomly add an integer value to change the image:
self.type = random(1,4)
if self.type = 1
change image
change size
if self.type = 2
etc...
Now when I check for collision, I don't check the image type anymore, but use your rule
Rule: When enemy gets hit:
-- change game.points to game.points+(self.type*100)
That works great, but I don't really have the power to set the exact point value anymore, as type will always be between 1 and 4. It probably would be better if I could do something like that when I chose the enemy type:
instead of...
self.type = random(1,4)
I could do something like...
self.type = random(enemy1points,enemy2points,enemy3points,enemy4points)
This way I would have control over the exact point value. Hope you understand what I mean. ;-)
But your suggestion at least helped me to throw out some conditions, thanks a lot! :-)
`
self.type = random(1,4)
if self.type = 1
change image
change size
change score value
if self.type = 2
etc...
`
when the enemy gets hit you could just do the following:
`change game.points to game.points+(self.value)`
By the way: thanks for all the answers I get here. That's really important if you're new to GS. :-)