How do I drag and drop pixel rounding

0 favourites
  • 15 posts
From the Asset Store
Vintage steam pixels for your UI! 125 unique assets in a single pack!
  • Hi,

    How do I create a drag drop system where it would move the block every x pixels (for example 32 pixels) then the other blocks would move accordingly to make space for the block I am moving.

      The movement would be horizontal only. The vertical axis will stay the same. There will be 4 or 5 blocks

    Here is an example of what I am thinking:

  • Something like this?

    Capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's exactly what I had in mind.

    I totally forgot about comparing the position based on the distance. I have used it for one of my games (puzzle).

    Thank you very much !!!

  • That's exactly what I had in mind.

    I totally forgot about comparing the position based on the distance. I have used it for one of my games (puzzle).

    Thank you very much !!!

    Not a problem!

    I actually read the question and thought, hmm interesting, let's see if I can make this work the way I think it would.

    And it did..

  • It works great at low speed but you have a bug if you drag the sprite quickly.

  • It works great at low speed but you have a bug if you drag the sprite quickly.

    Yep..

    That's what I hate about the drag and drop behaviour.

    When moving fast it's easy to miss the collision and or overlap.

    There are solutions for that though, the basics seem to work..

  • I believe the way to fix it would be to block the sides with another block or prevent the drag to go over board.

    This way the drag and drop would be limit to the 4 blocks positions.

    Does it make sense?

  • Ok, I'm working on a way to exchange the "is overlapping" for "pick nearest to the open space"

    Might take some time to get it perfect, but it would help against the high-speed-collision-detection-issue..

  • I believe the way to fix it would be to block the sides with another block or prevent the drag to go over board.

    This way the drag and drop would be limit to the 4 blocks positions.

    Does it make sense?

    Yeah, adding that would help also, but the speed of dragging can cause detections to be missed.

    The same sometimes happens with high bullet-speeds.

  • The same thing happens when you try to create a coloring game.

    since the mouse move too fast, Construct2 can't get all the coordinate in time. so it skips some.

    That's why when we drag to quickly, the other blocks bug.

    Ashley Is it possible to catch the mouse.X position quick enough to avoid the issue?

  • No, the operating system only updates the mouse at a certain frequency, and it's not possible to get it any faster. To solve this you have to step the position between the current mouse position and the last mouse position, simulating as if the mouse had really moved in small steps between those two points.

  • Ashley I see. I thought about this solution you mentioned but I couldn't put it together.

    Is there any example I could use? I looked it up online but I couldn't find anything useful.

    Thanks

  • This seems to work:

    updated capx

    Just added an is nearest to open spot - condition.

    Might still be it's possible to move too fast, but it's working a lot better than the last one, for it reacted to multiple overlap.

  • LittleStain That looks great. Thank you very much!

  • To prevent the player to move the blocks past the borders, I added this to the code

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