Need Help With Object Sliding Mechanism

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have 18 objects. Six of them will be in the gameplay area on a panel, and the rest will be outside the viewport. Every time the player starts the game, the six objects inside the gameplay should be random from those 18 objects.

    Also, while playing, if an object inside the viewport is destroyed, a new object from outside the viewport should automatically fill the space.

    (For example: if I destroy the 3rd object, the 4th, 5th and 6th will move one step to the left, and a new 6th object will be added on the right side of the panel.)

    Please help me achive this.

  • Add the objects to a Family and also use a Family instance variable for position.

    Randomness depends on what is allowed in your game. If it can be any object in the family and repeated then you can just 'create family' repeated 18 times, each time add 1 to the position variable and add +distance*var to the X position.

    For the sliding, assuming the above that they are all numbered in order due to family instance variable, when you destroy 'Family' store the family instance variable in a local variable, then pick all 'Family' objects where var is greater than the local variable and set their X to self.x-distance, or use move to behaviour to set their position and move them to self.x-distance.

  • Expected movement is exactly like this: webmshare.com/play/RLLeA

    if I place the 3rd object, the 4th and 5th will move one step to the left, and a new object will be added on the right side of the panel.

  • I got similar mechanism. Have a look:

    dropbox.com/scl/fi/ksf4g9kseczekqqs3xbdl/jigsaw_puzzle_pic.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Expected movement is exactly like this: webmshare.com/play/RLLeA

    if I place the 3rd object, the 4th and 5th will move one step to the left, and a new object will be added on the right side of the panel.

    Yes you described it well so I think what I suggested should work there :)

  • I got similar mechanism. Have a look:

    https://www.dropbox.com/scl/fi/ksf4g9kseczekqqs3xbdl/jigsaw_puzzle_pic.capx?rlkey=3z8l9amfgymmu5s2k6bnjvs7r&st=dvtkbs7b&dl=0

    Thanks you very much

  • > Expected movement is exactly like this: webmshare.com/play/RLLeA

    > if I place the 3rd object, the 4th and 5th will move one step to the left, and a new object will be added on the right side of the panel.

    Yes you described it well so I think what I suggested should work there :)

    Thank you very much

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