Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

speed applyForce
Started by mytamhuyet Mar 14 2019 07:59 AM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

mytamhuyet

[GLOBAL: userInfoPane.html]
mytamhuyet
  • Observer

  • 1 posts
  • Corona SDK

Hello! 

 

I want to make a game where I can move a ball in any direction of the screen by touch and below is the code that works fine to do this, but the ball is going too fast. I want the ball to go slower but at a constant speed. I have already tried to give the ball a density but then the speed isn't constant and then the speed depends on how far I reach my finger away from the ball. 

Some help would be great!

 

Greetings,



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 683 posts
  • Corona SDK

Hey!

Well, I don't see any code. :P

There are numerous methods to make objects move at a constant speed. As your title suggests using physics, I'd recommend looking into https://docs.coronalabs.com/api/type/Body/setLinearVelocity.html. Now, if the ball interacts with other objects or is affected by gravity, then the linear velocity will not remain a constant, so you'd need to keep constantly reapplying it in some runtime listener or after collisions, etc.

Without seeing your code or knowing more of what you are actually trying, it's not feasible to provide you with any more accurate answers.




[topic_controls]
[/topic_controls]