How can I make and Actor repeat an action more then once?
therobinsonbros@gmail.com
Member Posts: 34
The way I have my game set up, I have a small hitbox in the bottom corner of the screen. I want to be able to touch the hitbox and that will trigger a "Monster" actor to appear on the screen then fade away.
So far it works but it only work for one time, then I have to reset my game to do it again. I want to be able to do touch the hitbox over and over again and making the actor will appear and then fade away.
This is the code I have.
for Hitbox
Rule:
Touch is pressed
Do
Change Attribute set: game.hitbox
to: true
Then for my ( Monster Actor) I put.
Rule:
If game.hitbox is True
Do
change image set image to: "Monster" Actor
interpolate: Interpolate: self.color.alpha to: 0
for: 5 seconds
linear
Other info my hitbox is a "boolean" and my Monster actor is boolean as well.
So if anyone know what to do let me know.
So far it works but it only work for one time, then I have to reset my game to do it again. I want to be able to do touch the hitbox over and over again and making the actor will appear and then fade away.
This is the code I have.
for Hitbox
Rule:
Touch is pressed
Do
Change Attribute set: game.hitbox
to: true
Then for my ( Monster Actor) I put.
Rule:
If game.hitbox is True
Do
change image set image to: "Monster" Actor
interpolate: Interpolate: self.color.alpha to: 0
for: 5 seconds
linear
Other info my hitbox is a "boolean" and my Monster actor is boolean as well.
So if anyone know what to do let me know.
Comments
Way 1:
Set up a timer in a rule and have it say something along the lines of,
When game.hitbox is true
After 5 seconds---Run to competition
Change Attribute game.hitbox to false
Then after the 5 seconds is up, the attribute is false and the rules will work again and again after 5 seconds.
Way 2:
In the monster actor, have it say something along the lines,
All:
When game.hitbox is true
and
When self.color.alpha is 0
change Attribute game.hitbox to false
There are other ways you can do it also. The different ways depend on how you want it to work for your game. The main thing to note here is that you have to have the Attribute reset back to false each time for the rules to run through again! Hope that helps!
Artist/Game Developer / Animator at your service..
Personally I like to keep code simple so I'd dump all the is-hitbox-true-attribute stuff and just have a rule saying that when the hit box is touched spawn an actor wherever you want.
I'm not sure what's wrong. You way seem so simple it should work easy. Do you have any idea what could be wrong?
I know the way I normal do my fade away. I 1st use the image of the actor and place it on the screen, then I cover it with a blank actor. Not sure if that the right thing to do, but it got me this far.
for hitbox
Rule:
if touch is pressed
Do:
Change Attribute: game.hitbox to true
for monster actor
Rule:
if game.hitbox is true
Do:
Change image set image to "monster" actor
Interpolate: interpolate: self.color.alpha to 0
for 5 seconds
linear
change attribute: game.hitbox to false
rule
touch
DO
timer
After 1 sec
Spawn actor
------------------------
Hard way
Attribute spawn monster Boolean set to false
Rule in Hitbox actor
touch
Attribute Spawn monster = false
DO
Spawn actor
Timer for 1 sec
Change attribute to true
timer After 1 sec
Change attribute to false
Should only work when your attribute is false which it should start off as and turn to true than back to false in 1 sec after u click the Hitbox actor.
As for changing its alpha id just destroy the actor at a certain point or time that way there wont b actors build up in the background with 0 alpha.
In the monster actor put rules to make it move where u want
Also u can add a spawn limit by changing the attribute to integer and making the rule Less than or equal to a certain number. Its just a little harder.
In the monster actor u will have to add change attribute to game.SpawnLimit to game.spawnlimit+1 And when the monster gets killed change attribute spawn limit to -1
So u will be able to spawn up to a certain amount of enemies.