I’m trying to make a game where the user is supposed to drag a sprite up and down on the screen, avoiding incoming obstacles. The last answer here helped me to drag the sprite around on the screen, but I want to set a maximum speed the sprite can be moved (and hopefully with a natural-looking acceleration/deceleration), so it doesn’t get too easy to avoid the objects.
Does anybody know how I can modify the code to achieve this, or is there another way to to it?
Thanks 🙂
You’ll need to maintain a
CGPoint destinationPositionvariable which is the location of your finger and use an update loop to modify it’s position:In the
ifs, you might want to check if the objects are close to each other, rather than exactly the same number to allow for rounding errors.