how can I move a object inside the outline of other objects

Get help using Construct 2

Post » Wed Nov 18, 2015 4:27 am

how can I use the drag and drop behavior, to move a ocbjeto around the contour of another object? Imagine a square with only the color outline and inside unfilled. how can I make an object with behavior drag and drop to move only around the square without leaving the contour. I wish with this same logic, be applied if the cube was moving during the drag and drop, and I could use sprites with complex shapes like the outline of a star shape. imagine a hexagram, making for an object with the behavior drag and drop to move for each star line segment as the player podesse draw it
B
18
S
4
Posts: 48
Reputation: 1,088

Post » Wed Nov 18, 2015 6:32 am

You can do something like this:
Sprite1.X<Sprite2.BBoxLeft+Sprite1.Width/2--->Sprite1 Set X to Sprite2.BBoxLeft+Sprite1.Width/2

Just add 3 more conditions for right, top, bottom with appropriate values.
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Wed Nov 18, 2015 10:26 am

immortalx wrote:You can do something like this:
Sprite1.X<Sprite2.BBoxLeft+Sprite1.Width/2--->Sprite1 Set X to Sprite2.BBoxLeft+Sprite1.Width/2

Just add 3 more conditions for right, top, bottom with appropriate values.


One event with two actions will do:

every tick
sprite1 set x = clamp(sprite1.x,sprite2.bboxleft+0.5*sprite1.width, sprite2.bboxright-0.5*sprite1.width)
sprite1 set y = clamp(sprite1.y,sprite2.bboxtop+0.5*sprite1.height, sprite2.bboxbotto-0.5*sprite1.height)
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 Nov 18, 2015 11:14 am

@LittleStain thanks! I'm constantly learning a lot from you and it always amazes me how you can find the best solutions to problems. You have my deepest respect!
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Wed Nov 18, 2015 11:19 am

immortalx wrote:@LittleStain thanks! I'm constantly learning a lot from you and it always amazes me how you can find the best solutions to problems. You have my deepest respect!


Thanks..
Nice to hear..
Especiallly today (Birthday)
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 Nov 18, 2015 12:51 pm

Well, happy birthday to you my friend!
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Wed Nov 18, 2015 2:10 pm

Thank you very much immortalx and LittleStain. Very grateful for the help.
I will test and then write the result
B
18
S
4
Posts: 48
Reputation: 1,088

Post » Wed Nov 18, 2015 2:28 pm

@LittleStain
The move was perfect it moves the boundary! Is there a way to enable and disable the subject's with drag and drop behavior not move the center of the second object, move exactly at the edges? I could put an object inside and obstacle, but as I will create many objects in the layout I think I can lose performance.

I managed to make the move in the circle, but I would make the same objects with complex contour.



https:// dl.dropboxusercontent.com/ u/191465830/Manivela%202 /index. html
Last edited by vubidugil on Wed Nov 18, 2015 2:43 pm, edited 1 time in total.
B
18
S
4
Posts: 48
Reputation: 1,088

Post » Wed Nov 18, 2015 2:41 pm

That is a completely different question..

One way might be using a single tiled-background-object for all the borders and keeping the object overlapping that..
I can think of other ways using multiple imagepoints
Really depends on what you are aiming to do..

circle dragging is actually pretty easy as is dragging at the edges of squares..
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 Nov 18, 2015 2:47 pm

@LittleStain
Technically, I want to play use the touch screen, skirting the object as if it draws them.
Last edited by vubidugil on Wed Nov 18, 2015 2:52 pm, edited 1 time in total.
B
18
S
4
Posts: 48
Reputation: 1,088

Next

Return to How do I....?

Who is online

Users browsing this forum: alextro, stevenode and 4 guests