How do I stop overlapping?

0 favourites
  • 8 posts
  • hello, I have a one sprite that keep created randomly every 1 seconds...so how do i stop sprite overlapping with same sprite?

    I try if this

    "is overlapping another object". > destroy it

    but it turn out both of it is destroyed.

  • Create a family with this sprite and change your event to this:

    Sprite is overlapping SpriteFamily -> Destroy Sprite.

  • Create a family with this sprite and change your event to this:

    Sprite is overlapping SpriteFamily -> Destroy Sprite.

    hI dOP, It is also doing same thing when I tried it. Can you provide alternative where I can ensure that whenever new object is created it will be 50px away from previous one so that they never overlap each other and object is of size 50px?

  • > Create a family with this sprite and change your event to this:

    > Sprite is overlapping SpriteFamily -> Destroy Sprite.

    >

    hI dOP, It is also doing same thing when I tried it. Can you provide alternative where I can ensure that whenever new object is created it will be 50px away from previous one so that they never overlap each other and object is of size 50px?

    I coded something similar using Tynker. I think this solution will work using Construct 2.

    Have an invisible sprite that jumps to random positions.

    WHen the sprite is overlapping a clone/family, set a value to 1

    When the sprite isn't overlapping a clone/family, set a value to 0.

    Every 2 secs, set a random position for the sprite,

    Then if the value is 0, create a clone. wait?

    If the values 1, set position to a random position and repeat the process.

    I used this with Tynker to draw hundreds of balls onscreen in different sizes without the balls overlapping each other.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • >

    > > Create a family with this sprite and change your event to this:

    > > Sprite is overlapping SpriteFamily -> Destroy Sprite.

    > >

    >

    > hI dOP, It is also doing same thing when I tried it. Can you provide alternative where I can ensure that whenever new object is created it will be 50px away from previous one so that they never overlap each other and object is of size 50px?

    >

    I coded something similar using Tynker. I think this solution will work using Construct 2.

    Have an invisible sprite that jumps to random positions.

    WHen the sprite is overlapping a clone/family, set a value to 1

    When the sprite isn't overlapping a clone/family, set a value to 0.

    Every 2 secs, set a random position for the sprite,

    Then if the value is 0, create a clone. wait?

    If the values 1, set position to a random position and repeat the process.

    I used this with Tynker to draw hundreds of balls onscreen in different sizes without the balls overlapping each other.

    Thanks for replying. Your solutions sounds promising but sounds very complex. Can you share capx for same?

  • Alternatively you can use the custom movement behavior's "push out solids" action, although the usage is a little situational.

  • I coded something similar using Tynker. I think this solution will work using Construct 2.

    Have an invisible sprite that jumps to random positions.

    WHen the sprite is overlapping a clone/family, set a value to 1

    When the sprite isn't overlapping a clone/family, set a value to 0.

    Every 2 secs, set a random position for the sprite,

    Then if the value is 0, create a clone. wait?

    If the values 1, set position to a random position and repeat the process.

    I used this with Tynker to draw hundreds of balls onscreen in different sizes without the balls overlapping each other.

    Thanks for replying. Your solutions sounds promising but sounds very complex. Can you share capx for same?

    I made 2 squares. A blue and red square.

    The blue squares 20,20 size. The red squares 16,16 size and in Family 1.

    The blue square has an instance variable "Sensor"

    Here's what i coded

    SYSTEM-every 0.05 seconds:------------------------------BLUE, set position to random X(2,679) Y(2,479)

    BLUE-Sensor = 0: Set Sensor to 1

    BLUE-Sensor = 1:----------------------------------------------BLUE, spawn Family 1

    BLUE-not overlapping Family 1: Set Sensor to 0

    BLUE-Sensor =1:----------------------------------------------Set Sensor to 0

    Family 1- is overlapping BLUE BLUE, set position to random X(2,679) Y(2,479)

    This filled the screen with Red squares/Family 1 members, that didn't overlap each other

  • Here you go:

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