How do I drag and drop pixel rounding

Get help using Construct 2

Post » Tue Apr 14, 2015 9:16 pm

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:
Image
B
112
S
46
G
24
Posts: 400
Reputation: 21,889

Post » Wed Apr 15, 2015 1:39 pm

Something like this?

Capx
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 3:11 pm

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 !!!
B
112
S
46
G
24
Posts: 400
Reputation: 21,889

Post » Wed Apr 15, 2015 3:16 pm

jogosgratispro wrote: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.. :)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 3:27 pm

It works great at low speed but you have a bug if you drag the sprite quickly.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,610

Post » Wed Apr 15, 2015 3:35 pm

ramones wrote: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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 3:50 pm

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?
B
112
S
46
G
24
Posts: 400
Reputation: 21,889

Post » Wed Apr 15, 2015 3:51 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 3:55 pm

jogosgratispro wrote: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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Apr 15, 2015 6:32 pm

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?
B
112
S
46
G
24
Posts: 400
Reputation: 21,889

Next

Return to How do I....?

Who is online

Users browsing this forum: gianghl1983, Google [Bot] and 9 guests