Remove actor?

Hi all,

So I'm having an issue with removing an actor.

Right now, I have one actor with a behavior to spawn another actor, triggered by the user's touch.
This new actor is spawned directly on top of the first, touched actor. I want the new actor to be destroyed when the user lifts their finger.

So basically, tap this guy ---> an actor appears
Release your finger from the screen ---> that new actor is removed

As I have it, the new actor appears. But I can't seem to figure out a way to have that actor destroyed when the user is no longer touching.

Any help is appreciated!
Thanks,

Comments

  • RPRP Member Posts: 1,990
    edited February 2013
    Maybe rather than going the spawn and destroy method, use interpolate behaviors. So when you press on touch your actor (you intended to destroy), it goes invisible via Alpha = 0. Then when touch releasing (the actor you want to appear), the new actor appears Alpha = 1.

    What kind of game do you have set up? If it is a static screen (just one screen), you could set up a grid of touch boxes, but more info will be needed before more suggestions come.
  • AdrenalineAdrenaline Member Posts: 523
    Thanks RP!
    It is a static screen. Basically, I want the user to touch an actor and then that actor changes appearance and behaviors. When the user releases the touch, it reverts back to its original appearance and behaviors. I thought the best way to do this would be to have an actor (with the new appearance and behaviors) spawn...and destroy when it's not being touched by the user.
    I'm not sure if the alpha idea will work, because that means it's there the entire time, right? So it's behaviors will be active. Maybe I could set a rule that only activates the behaviors when its alpha is 1?
  • SocksSocks London, UK.Member Posts: 12,822
    Maybe rather than going the spawn and destroy method, use interpolate behaviors. So when you press on touch your actor (you intended to destroy), it goes invisible via Alpha = 0. Then when touch releasing (the actor you want to appear), the new actor appears Alpha = 1.
    Yeah, that sounds like a better method - you can stick the return to Alpha = 1 in 'otherwise'

    When Touch is pressed:
    Change Alpha to 0
    Otherwise:
    Change Alpha to 1
  • AdrenalineAdrenaline Member Posts: 523
    Thanks guys
  • selectsoftselectsoft Member, PRO Posts: 38
    What about... on touch count = 0, destroy
  • selectsoftselectsoft Member, PRO Posts: 38
    edited February 2013
    but, RP's suggestion is way more efficient... I'd use that instead for sure.
Sign In or Register to comment.