did you open the Keyboard Entry Demo from GS … third Row in New ???
3rd scene shows how to have a lifeBar above the actor … think making multipleInstances of that lifeBar … each constrained to an actor, might work for you
The thing is that I'm re-spawning the same actor, like 10 times for example. So how can I tell which one is which and secondly do I need to create a constrained atribute for each of them?
okay see the problem … hopefully, see the solution
on prototypeActor that you are spawning: add an attribute Index type … name: myLives … set to the number/amount of lives (5 ???) in behaviors Rule: when Event: collides --changeAttribute: self.myLives To: self.myLives-1
Rule: when Attribute: self.myLives = 0 --Destroy ==== to tell which spawnedActor is which: gameAttribute Index type … spawnNumber = 0
on Spawner: just before the spawn changeAttribute: game.spawnNumber To: game.spawnNumber+1 then spawnBehavior
on prototypeActor being spawned: another attribute Index type … my# behaviors: changeAttribute: self.my# To: game.spawnNumber
Thank you for the help... Yes I was on the same way to figuring out which one is which, I just added an extra rule to avoid that the spawn number was set to all the actor by adding that spawn number need to be equal to zero be be change. This means that the actor spawn number will only be changed once.
But still my problem is how to create multiple energy bar above the actor? do I need to create new constrain x and y for each of the spawn actors? I was thinking about the table to write the values there but this feature is still not available :S
Hi MH thank you so much for the help, Yesterday I found a different way to solve this problem, because may main propose was to try no to have to create 2 contrains for each new spawn actor, and have an automatic away. The question is and I hope you can help me is to figure out if the solution I found is the best in terms of performance? Just to give a bit of more information, I'm trying to do a kind of tower defense game, so I will need to have a lot of actor with energy bar in the game.
For my solution was each time the actor was spawn we will spawn a new energy bar using the self x and y of the actor with a time rule to refresh every 0.01 sec. In the energy bar I just create a rule with time is it would destroy itself also every 0.01 sec.
It works fine but if I add more then 6 actor the others actor in the game start to have a strange behavior, so the game starts to have performance issues :S
What do you think? do you know which solution will be better?
Timers … numerous timers… really slow things down and mess-up firing calls … Especially Timers that are "Every:"
So having 2 everyTimers on 6 Actors is 12/scene … set to fire a behavior every 0.01 seconds? … plus you have everyTimers on the spawners to re-spawn every 0.01 sec?
think you have to reference/call your behavior actions differently …
Comments
3rd scene shows how to have a lifeBar above the actor …
think making multipleInstances of that lifeBar … each constrained to an actor, might work for you
@};- MH
on prototypeActor that you are spawning:
add an attribute Index type … name: myLives … set to the number/amount of lives (5 ???)
in behaviors
Rule: when
Event: collides
--changeAttribute: self.myLives To: self.myLives-1
Rule: when
Attribute: self.myLives = 0
--Destroy
====
to tell which spawnedActor is which:
gameAttribute Index type … spawnNumber = 0
on Spawner:
just before the spawn
changeAttribute: game.spawnNumber To: game.spawnNumber+1
then spawnBehavior
on prototypeActor being spawned:
another attribute Index type … my#
behaviors: changeAttribute: self.my# To: game.spawnNumber
@};- MH
Thank you for the help... Yes I was on the same way to figuring out which one is which, I just added an extra rule to avoid that the spawn number was set to all the actor by adding that spawn number need to be equal to zero be be change. This means that the actor spawn number will only be changed once.
But still my problem is how to create multiple energy bar above the actor? do I need to create new constrain x and y for each of the spawn actors? I was thinking about the table to write the values there but this feature is still not available :S
tks in advance for the help
Pedro
how many of the Actor's needing lifeBars do you intend to have on the screen at one time? 5? 10?
please email me at gmail I will send you a demo …
@};- MH
tks
hope it helps
@};- MH
thank you so much for the help,
Yesterday I found a different way to solve this problem, because may main propose was to try no to have to create 2 contrains for each new spawn actor, and have an automatic away.
The question is and I hope you can help me is to figure out if the solution I found is the best in terms of performance?
Just to give a bit of more information, I'm trying to do a kind of tower defense game, so I will need to have a lot of actor with energy bar in the game.
For my solution was each time the actor was spawn we will spawn a new energy bar using the self x and y of the actor with a time rule to refresh every 0.01 sec.
In the energy bar I just create a rule with time is it would destroy itself also every 0.01 sec.
It works fine but if I add more then 6 actor the others actor in the game start to have a strange behavior, so the game starts to have performance issues :S
What do you think? do you know which solution will be better?
tks
Pedro
Especially Timers that are "Every:"
So having 2 everyTimers on 6 Actors is 12/scene … set to fire a behavior every 0.01 seconds? …
plus you have everyTimers on the spawners to re-spawn every 0.01 sec?
think you have to reference/call your behavior actions differently …
would like to look at your project file …
@};- MH