How do I create gibs (break apart pieces) of a sprite.

0 favourites
  • 5 posts
From the Asset Store
80 pieces of loopable game music, 10 game overs and 10 level complete pieces.
  • I am creating a game in which you fly a space ship. I want the ship to break into many different pieces when it gets destroyed. I have it set up to remove the base sprite and replace them with pieces i chopped up in a photo editor. I just need to know the best way about getting them to take the place of the original ship, and then slowly float apart.

  • Theres a few ways you could do something like this. I would use the pin behaviour initially, and then disable it and apply different velocities to the individual pieces. Eg if you assemble the ship out of the broken parts outside of your play window - then when your main ship is destroyed call an action which pins the ship pieces together (if they're set up correctly on the layout it will pin them as they are layed out) then destroy the main ship whilst swapping out the position of the ship pieces to where the ship was. Then unpin them and apply force to each piece.

  • I would make 2 animations.

    Animation 1 = ship that breaks up towards complete transparantion. Lets say, if the nose breaks off, this animation has on that place nothing.

    Animation 2 = all the parts. Animation speed set to zero.

    When the ship gets destroyd. You start animation 1.

    When animation 1 is at frame 0, spawn the sprite with animation 2. Set its frame to the first part. Move it in a direction that you want to.

    When animation 1 is at frame 1, spawn the sprite with animation 2. Set its frame to the second part ..

    And so on.

    Destroy object with first animation on animation end.

    Destroy the spawn parts with a timer behaviour.

    Ofcourse you will have to us 'once while true' with the frame comparing.

  • I think the other replies may have missed your last sentence.

    [quote:33xgymb2]I just need to know the best way about getting them to take the place of the original ship, and then slowly float apart.

    I don't have a nice easy solution to this, but I'm guessing there isn't one.

    I would just bite the bullet and set the individual pieces to the right positions and angles when you create them.

    If they have the physics behavior, you might need to be careful with the collision polygons overlapping.

    If you want to set this up without needing to test it constantly, I'd suggest disabling all collisions/physics/moving parts and place each gib where it should be over the object. Then you can print out the position of each (relative to the main object) and move it by that much when they are eventually created.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)