When I'm building a sprite, I always try to make it as 'independent' as possible, so it can be replicated and re-used in other project with minimum code changes during 'copy'.
for example I have a spaceship in a shoot-em-up game and I want it to appear in screen in different positions each time I call it to 'launch'. So I create in the sprite the internal initx and inity variables. But the launcher object cannot 'modify' these variables for my sprite.
I know that one suggestion is to make the variables global, but when I want to replicate the sprite to create a second, third, etc. enemy, their 'global' initx and inity will conflict.
It would be good to have a reverse variable sensor to say
set 'variable of object' to value (similar to the way you can read the value).
What I'm doing right now is use a list of global initx and inity and have my sprite copies have a different index and read initial values from there. But it's not so elegant.
Anyone bump onto this? Or found an elegant solution?
Offline
killerchip wrote:
When I'm building a sprite, I always try to make it as 'independent' as possible, so it can be replicated and re-used in other project with minimum code changes during 'copy'.
for example I have a spaceship in a shoot-em-up game and I want it to appear in screen in different positions each time I call it to 'launch'. So I create in the sprite the internal initx and inity variables. But the launcher object cannot 'modify' these variables for my sprite.
I know that one suggestion is to make the variables global, but when I want to replicate the sprite to create a second, third, etc. enemy, their 'global' initx and inity will conflict.
It would be good to have a reverse variable sensor to say
set 'variable of object' to value (similar to the way you can read the value).
What I'm doing right now is use a list of global initx and inity and have my sprite copies have a different index and read initial values from there. But it's not so elegant.
Anyone bump onto this? Or found an elegant solution?
+1
Offline