How do I make an object move in circular path while i am draging horizontally on the screen?

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • How do I make an object move in circular path while i am draging horizontally on the screen. Attaching a video.

    https://youtube.com/shorts/F5bxWX3Lm04?feature=share

  • If I understand your problem correctly, you have 360 degrees of movement and whatever width you have on the bar. It shouldn't be more complex than a rule of three to translate one value to the other.

    As a side note, I would pin the ball to a point on the object you are actually spinning. It feels like the minimal way to do it.

    Hope that helps.

  • Hello thanks for you reply

    bit still i did'nt get your point can you elaborate a bit more

  • You can place an object on the edge of a circle with:

    X=radius*cos(a)+centerX

    Y=radius*sin(a)+centerY

    To make it move around the circle you’d change “a”. One way to do it is:

    A=mouse.x

    Or you can tune that

    A=(mouse.x-scrollx)*factor+startAngle

    Where we subtract the scrollx to have a centered mouse result in no rotation. Factor is basically how fast the rotations come from the mouse position. And startAngle is where you want to start rotating from.

    That was for calculating an angle from mouse.x in an absolute way. You can do it relatively too.

    Var startX=0

    On touch start

    — set startX to touch.x

    Is touching

    — add touch.x-startX

  • I'm 100% sure that ROJO's approach is valid, but I still don't think it is the most minimal form of the solution.

    The process below is what I described above.

    EDIT: just keep in mind that if you want to change the precision, change the steps in the SlideBar, and not the maximum value.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thank you so much will try this

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