Corona SDK and moving objects
I have shapes (Rectangle) in my game and want to implement something like - when the shape object is pressed for small amount of time and pushed in any direction it should move small distance but pressing the shape for longer time it should be moved to large distance ( means depending on the pressure put on the shape and开发者_StackOverflow社区 when it is thrown it should move distance relative to pressure applied.
Regards
You can break the problem into two pieces:
- While the object is being pressed, it accelerates (so the longer it is pressed the greater the speed it gets up to).
- As it travels, it decelerates at a constant rate (so the faster it's going at the beginning, the longer it keeps moving, and the farther it moves before it stops).
Now all you have to do is implement velocity and accelaration, then pressure and drag.
If this approach doesn't give the appearance you want, there are ways to modify it.
精彩评论