How do I make this custom swipe

Get help using Construct 2

Post » Tue Jan 17, 2017 8:38 pm

It would be funny if all he wanted was a on/ off switch.
Image ImageImage
B
171
S
50
G
180
Posts: 8,396
Reputation: 113,986

Post » Tue Jan 17, 2017 10:41 pm

R0J0hound, thank you, it's a working example, what about other shapes ? If the pipe is a square or triangle ?
B
8
S
3
Posts: 6
Reputation: 612

Post » Wed Jan 18, 2017 1:34 am

I've yet to get a working solution to that. The idea is the ball can move in a narrow corridor and it tries to move toward the mouse, and it will slide against the walls.
B
94
S
33
G
114
Posts: 5,360
Reputation: 73,781

Post » Wed Jan 18, 2017 2:41 am

Image ImageImage
B
171
S
50
G
180
Posts: 8,396
Reputation: 113,986

Post » Wed Jan 18, 2017 8:56 am

The path itself can be defined any way you want. The spine suggestion is a valid way to do it. The hard part is dragging the object along a path which is different than having the object move along a path.
My example with an arc just simply moves the object to the closest point on the path. That works well since the path is mostly in a line. I guess just moving to the closest point would work for a triangle, square or circle as well. The only issue in my mind is you can then move directly across to the other side instead of having to go around the edge. Using the closest point wouldn't work well for more complex paths.

My incomplete idea for a better general case solution would be to make the path a polyline since it's simple enough to constrain dragging to a line. Then when a corner is hit it decides which line segment to move on based on the direction to the mouse.
An alternate idea would be to find the closest point and the find the closest distance along the path, and have the object start moving in that direction.

But perhaps the closest point is good enough. That involves finding the distance to all the corners and all the edges and selecting to closest one. The distance to the lines is the more mathy one.

The absolute simplest way would be to put invisible walls around the path with sprites, move the the object toward the mouse with the "move at angle" action, and use the custom movement behavior's "push out" action.
B
94
S
33
G
114
Posts: 5,360
Reputation: 73,781

Post » Wed Jan 18, 2017 2:26 pm

R0J0hound wrote:The path itself can be defined any way you want. The spine suggestion is a valid way to do it. The hard part is dragging the object along a path which is different than having the object move along a path.
My example with an arc just simply moves the object to the closest point on the path. That works well since the path is mostly in a line. I guess just moving to the closest point would work for a triangle, square or circle as well. The only issue in my mind is you can then move directly across to the other side instead of having to go around the edge. Using the closest point wouldn't work well for more complex paths.

My incomplete idea for a better general case solution would be to make the path a polyline since it's simple enough to constrain dragging to a line. Then when a corner is hit it decides which line segment to move on based on the direction to the mouse.
An alternate idea would be to find the closest point and the find the closest distance along the path, and have the object start moving in that direction.

But perhaps the closest point is good enough. That involves finding the distance to all the corners and all the edges and selecting to closest one. The distance to the lines is the more mathy one.


The absolute simplest way would be to put invisible walls around the path with sprites, move the the object toward the mouse with the "move at angle" action, and use the custom movement behavior's "push out" action.


Thank you, i was thinking the same, maybe adding more points to "spine" will make it more accurate .. anyway need to find out how to code that.
B
8
S
3
Posts: 6
Reputation: 612

Post » Tue Jun 20, 2017 12:55 pm

Message: user5487 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
R0J0hound wrote:Another idea is the curve looks to be an arc on a circle. Here's one idea to constrain the ball to that arc:
https://dl.dropboxusercontent.com/u/542 ... pprox.capx

To make it perfect you'd need to tweak stuff. The radius, lowAng, highAng, the angle of the track and the origin of the track.



i want this link , can you or anyone please reupload this file ? thanks
B
5
S
1
Posts: 14
Reputation: 403

Post » Tue Jun 20, 2017 5:42 pm

link updated
B
94
S
33
G
114
Posts: 5,360
Reputation: 73,781

Post » Tue Jun 20, 2017 8:42 pm

R0J0hound wrote:link updated

thanks a lot :]
and how can i get those variable values for another sprites etc (radius lowAng highAng)?

and what if my sprite was Horizontal or vertical ?
B
5
S
1
Posts: 14
Reputation: 403

Post » Wed Jun 21, 2017 5:26 pm

Make a circle sprite and resize it in the editor till the start and end positions are on the edge of it. That's your radius.
Then run the layout and set a text object to angle(circle.x, circle.y, start.x, start.y) to get the lowAng. Do the same with the end position to get the highAng. You may need to swap lowAng and highAng if it doesn't work.
B
94
S
33
G
114
Posts: 5,360
Reputation: 73,781

Previous

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 10 guests