How do I swipe to fling object?

0 favourites
  • 7 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • How can I swipe an object to fling it in the direction of the swipe, but only once? For instance, an overhead shot of a golf ball on a tee. you swipe over it to fling it once to see how far it goes.

  • You need to know the start of swipe (x,y) and end of swipe (x,y) then find the angle and distance from start-to-end to find the direction and power of impulse at which the ball should be hit.

    Like this: https://drive.google.com/file/d/1H4RdrvEPPUx43PRb08v1whBxC-icAdIX/view?usp=sharing

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • el constructor thanks a lot for the quick reply and C3P example. this gives me another way of trying to do it. right now i am trying with the bullet behavior:

    -> Sprite: Set Bullet speed to distance(Sprite.X,Sprite.Y,Touch.X,Touch.Y)×10

    -> Sprite: Set Bullet angle of motion to angle(Sprite.X,Sprite.Y,Touch.X,Touch.Y) degrees

    One thing to note is that your example allows you to continue swiping and flinging the ball. I am looking for only one swipe/fling. I figured out I can do this by adding a fling/swipe area around the start of the ball, and as long as the ball is overlapping with the swipe/fling area, it will fling. if not, it won't. so I think that works.

    thanks again. I think I may switch this to physics.

  • You're welcome.

    Yep, that will work. So instead of any touch start, it would be On touching object (invisible region). (Then hide the region from there)

    Also, if you want to enable more flinging when the Ball comes to ground and stops again (like in Golf).. then you can just bring back the invisible region on the Ball.X, Ball.Y when Ball.Physics.OverallVelocity < 0.1

  • Hey man, the game I'm currently making uses similar physics to what your after.

    Little capx to show you another possible use of physics that allows you to visibly show the amount of power you are using.

    drive.google.com/file/d/13fcazC_bhYalOwP_6OlYqDFuyucOcRDW/view

  • You're welcome.

    Yep, that will work. So instead of any touch start, it would be On touching object (invisible region). (Then hide the region from there)

    Also, if you want to enable more flinging when the Ball comes to ground and stops again (like in Golf).. then you can just bring back the invisible region on the Ball.X, Ball.Y when Ball.Physics.OverallVelocity < 0.1

    Exactly. Just regenerate the swipe circle for more swiping. Thanks again for the physics example. I think I might use it for another idea.

  • Hey man, the game I'm currently making uses similar physics to what your after.

    Little capx to show you another possible use of physics that allows you to visibly show the amount of power you are using.

    https://drive.google.com/file/d/13fcazC_bhYalOwP_6OlYqDFuyucOcRDW/view?usp=sharing

    Thanks for the extra example. I'll give this a try and see how I can use it. Good luck with your golf game.

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