iphone - Final position of a Sprite in cocos 2d based on swipe angle and speed -


how final position of sprite in cocos 2d when swiped @ speed , angle ?

are looking 'fling' sprite across screen? ask since mentioning angle , speed.

if so, can ignore angle , concentrate more on length , direction of swipe since give vector can apply sprite.

in cctouchbegan need store initial point coordinate of touch.

in cctouchended have final touch point, can use little pythagoras calculate distance between 2 points. have length of swipe.

to calculate speed need calculate time between touch , release , use calculate how many units touch moved per timestamp.

where resting point of sprite will depend on how applying force sprite. if applying swipe vector sprite, imagine updating sprites position based on velocity during update? check position need apply same formula use there pass in arbitrary timestamp take place of delta time. let see object end in t seconds.

call multiple times increasing values of t until sprite's position stationary , have resting point.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -