Reviving Actor

EpicoreGamesEpicoreGames Member Posts: 188
edited February 2015 in Working with GS (Mac)

Like in my game , I set my actor to die when it's HP ( an integer ) equals to 0
And I want it to revive when the HP integer is equals to 1 ( I have a rule which says when SELF.HP = 1 , SPAWN ACTOR )
I've made a rule which contains :
When TOUCH is PRESSED ,
Change SELF.HP to 0 ( I have another rule about when SELF.HP = 0 , DESTROY THIS ACTOR )

So now my actor is destroyed and I want it to revive and run the spawn actor behavior again . So I add a behavior and change SELF.HP to 1 . However , the actor doesn't revive after it is destroyed .

I wonder where should I put the change SELF.HP to 1 behavior . I've tried putting it outside the blocks and in the rule of "when TOUCH is pressed ...... " ( after the change HP behavior ) and both of them didn't work .

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    If you destroy an actor, it removes it from the scene. At that point, the actor won't run any of its rules or do anything. You might consider hiding it instead (Change Attribute self.Color.Alpha to 0, and then back to 1 when you want to 'revive' it).

    You can also have a different actor spawn the actor again when needed.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    If you destroy an actor, it removes it from the scene. At that point, the actor won't run any of its rules or do anything. You might consider hiding it instead (Change Attribute self.Color.Alpha to 0, and then back to 1 when you want to 'revive' it).

    Yep, switch it off by making it invisible, or as an alternative move it (instantaneously) off screen or change its size to x0, y0 (and probably many other ways to temporailiy hide an actor)

  • EpicoreGamesEpicoreGames Member Posts: 188

    Okay thank you @tatiang and @Socks . :)

Sign In or Register to comment.