Topic was automatically imported from the old Question2Answer platform.
Asked By
kakidon
Hello,
Sorry for amateur question as I am a beginner in game development. I am not able to find a way to implement the animation based on touch. Basically more the user drags the touch , the more the rope should be pulled. I can create a animation player for end and starting points, but getting confused as to how to control its pulling length.
Please refer to this video , i am talking about the rope where the bird is placed. The concept i am trying to implement is similar to pulling a rubber band.
My initial thought would be to make the rubberband a seperate scene with a sprite, a tween and an anchor point (maybe a position2d?).
In its (the rubberbands) process function I would have written something like this piece of pseudo-code:
process(delta):
get distance between finger input and anchor point
get angle bewteen anchor point and input
clamp the values to minimum and maximum values, so you dont get overexaggerated results
tween the rubberband sprite the evaluated distance and angle
Just an idea, maybe someone knows a better or more elegant way. You can check the docs if there are functions to help make the calculations or you could calculate it by code with vector math. Here is a really good explanaiton on vector math, if you have not read it already: