How do I make this custom swipe

0 favourites
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hi guys, i'm new to construct 2, how i can create a directional swiper when you need to click from point 1 and drag to poin 2 and not cross the sprite border ? The other question is how to apply sprite efect to just part of the sprite (where the current mouse position is). Thank you for any help.

  • On any touch start, set variable startx to touch.x, set variable starty to touch.y

    On anytouch end

    ->compare variable startx is less than touch.x

    -->compare variable starty is less than touch.y, do foo

    Im not sure what you mean by sprite border.

    For a trail just add an event to spawn a sprite at mouse x,y when in touch, then add the fade behavior.

  • I need to swipe the button from point 1 to point 2 exactly on specific trajectory, like on the pic.

  • There's a big difference between a swipe, and a curve gesture.

    A swipe has a start, and an end point, and can have direction as well as speed.

    Its fairly easy to do.

    A curve gesture on the other hand also has a start and an end, but will sample multiple points in the movement to determine if it meets the loose definition of the specific gesture.. There's a few diferent ways to implement it, all of which are somewhat complicated.

    Theres also a plugin which is overkill for such a simple gesture, but it would be the simplest method.

    Welcome to the rabbit hole.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There's a few diferent ways to implement it, all of which are somewhat complicated.

    Thank you, can you give me a hint of what could be the implementations ?

  • A simple method would be to average the points between the first and last point, and determine if that point was close to the midpoint, but still on the side of the hypotenuse.

  • wow... i wont lie, i didnt understand anything from your message.

    I`ll add new image, maybe i wrongly described what i want to accomplish.. i want to drug the ball along the curved shape of the pipe.

  • If the path is predetermined, and just needs the drag start I'd suggest taking a look at

    My first post should suffice as a trigger for a spline movement.

  • Newt first post is indeed the solution that you need to replicate along the way of your picture.

    You need to calculate in a row that your user moves from Start to 1, and then from 1 to End, and when they arrive to End, that they went through 1.

    So you need some global variable or array and change the value when Start to 1 has been successfully completed.

    It is a bit involved for a complete newcomer.

    Take your time, read several times all the informations provided here and be sure to read through the manual to learn more on Construct 2 and how it works.

    If you need further explanation be as accurate as possible and you'll get accurate answers. If you don't understand this topic yet, you may not be ready to implement such a mechanic yet.

  • 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://www.dropbox.com/s/weiffpc1dnhb8 ... .capx?dl=1

    /examples34/track_drag_approx.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.

  • It would be funny if all he wanted was a on/ off switch.

  • R0J0hound, thank you, it's a working example, what about other shapes ? If the pipe is a square or triangle ?

  • 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.

  • 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.

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