How do I create a new sprite when two similar sprites collide ?

0 favourites
  • 5 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • I make a simple game with colored balls falling from the top of the screen. When a red ball collides with another red ball, a green ball is created right in the middle of the segments connecting the two red balls centres and both red balls are destroyed.

    Logic is not a problem, I'm just looking for a method to get red ball's (0) and Red ball's (1) instances coordinates in order to calculate the green ball's coordinates.

    Green.X=abs(Red.X(0)-Red.X(1))/2

    Green.Y=abs(Red.Y(0)-Red.Y(1))/2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The usual response to this is to use a family, so it would be Red overlaps with Family where the Family is also the Red object, but for picking purposes it means you can use Family for the first ball and Red for the second.

    There is also something under system called pick nth instance where 0 and 1 would be the two instances in the collision, problem here is I'm not sure how it differentiates either one (could be IID). If it doesn't matter which is 0 and 1 then this could be a method you can use.

  • I actually gave it a try with family, but when destroy action occurs, every instance in family is also destroyed :/

  • The original red ball that collides must have something unique to the condition as it sounds like all balls are colliding.

  • I found a way to have it working using family

    - Red sprite is in Red family

    - When Red sprite collides with Red family instance, create a new sprite at the middle of Sprite and Family instance position. Construct uses coordinates of both elements involved in collision and everything works fine :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)