Explosion animation where actor was touched

jerlant360jerlant360 Member Posts: 82
edited November 2012 in Working with GS (Mac)
i have a falling actor who when is touched goes back again (recycled) the thing is i want that appears an explosion on the place where it was touched

Thanks guys

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Spawn an actor on him with an explosion animation and then destroy when animation is complete.
  • jerlant360jerlant360 Member Posts: 82
    The issue is that the explosion animation move with the actor and goes back again
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    @jerlant360 Hi, not sure why the spawned explosion would follow your actor, unless you've put a Rule to tell it too...

    Good advice from @FryingBaconStudio which should work fine without problems... OK, try something like this: put your Animate behaviour for the explosion in its own actor's rules as suggested

    In the rules of your falling actor, put:

    Rule when touch is pressed
    Spawn Explosion

    --- I'm sure you did that, but put its Position in the Spawn behaviour, x as game.Touches.Touch1.X and y: game.Touches.Touch1.Y Relative to scene

    Then make sure your explosion actor to be spawned is set to not move, i.e Moveable unchecked in its Physics attributes.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    edited November 2012
    Good advice from both @gyroscope and @FryingBaconStudios, but couldn't you just have that same actor be the explosion? Just say:
    When touch is pressed,
    Animate : (add frames)
    Timer, after x amount of seconds,
    Change attribute self.position X to (whatever)
    Change attribute self.position Y to (whatever)

    Maybe I'm missing something or don't understand the question fully...
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    All you have to do is put the spawn behavior in the main actor and have it spawn the explosion relative to actor this should happen in the code before recycle. The animation will stay where spawned and then should be set with a timer for duration of animation to destroy.
  • KnightStarKnightStar Member Posts: 162
    If you're concerned about spawning a new actor and then destroying the actor, one trick I did in one of my apps was to change the actor - in your case, the falling actor - into the explosion.

    In my game, I had missile launching into the air and at a certain point (i.e. touch), I Changed the Image to the first frame of my explosion, adjusted the size of the actor (Change Attribute Size X & Y), and then played the animation. On the last slide of the animation, I created a blank transparent slide. Upon the end of the animation (this took some trial and error with a timer), I used Change Attribute to recycle the actor back to a starting position (I recycled missiles - I had 15), reset the image back to a missile and changed the Size back to normal.

    As I said above, I ended up with 15 missiles to permit the game to display a steady stream of missiles firing while also allowing enough time for the animation sequence to play and the missile actor to reset off-screen.

    While it was a bit of a pain setting up all 15 missiles, it ended up being very efficient.

    Note - you can include a rule within your falling actor to only be affected by Touch input in non-explosion mode, permitting spam-fingered players from affecting the actor while it's in it's explosion behavior..

    - Cheers!
  • jerlant360jerlant360 Member Posts: 82
    Hey guys thanks for your help , i don't know why it didn't work before , i already resolved it thanks to you all @FryingBaconStudios @gyroscope @Braydon_SFX @KnightStar Thanks a lot :D
Sign In or Register to comment.