Camera accelerate and decelerate with scroll

Started by kkl, December 15, 2014, 02:29:40 AM

Previous topic - Next topic

kkl

Hi,

Has anyone tried camera smooth scrolling before? Something like, the camera accelerates based on velocity and slows down(decelerate) when the touch event stops.

EgonOlsen

Should be simple to do. Or do you have any issues with it?

kkl

#2
It's easy if the camera moves according to the distance of the scroll, but it would look artificial and the scrolling is not smooth. I kinda stuck at scrolling acceleration and deceleration parts. Does it involve with velocity?

EgonOlsen


kkl

I've never tried physics stuff before. Do you know any good library or tutorial that might helps?

EgonOlsen

I don't think that this needs a library. If you have a target speed for each frame, just try something like


camSpeed=(5*oldSpeed+targetSpeed)/6;
oldSpeed=camSpeed;


Then again, i'm still not entirely sure what you actually want to implement, so my suggestions might be totally missing the point... ;)

kkl

Tat works like magic! Exactly wat i've been looking for.. but i still hav problem if the camera moves to the edge(i set a position limitation to left and right) and the scroll just stop right away instead of smooth scroll to edge. Do you have any idea to fix tat?