Camera Zoom and Move

Camera Zoom and Move
0.0 0


Hello EveryOne

Please help me!

I want to zoom and move camera same iStunt2 game, but movement and zoom can not be smooth as iStunt.
I use setScale and setPosition:

Move camera on update function:
offsetx = 0.05;
offsety = 0.05;
b2Vec2 position = frame~~>GetPosition;
CCPoint myPosition = getPosition;
myPosition.x = position.x * PTM_RATIO;
myPosition.y = position.y * PTM_RATIO;
float xnext = this~~>getScale;
float offx = xnext~~ this->getPositionX;
= offsetx;
xnext = this~~>getPositionX()+offx;

float ynext = (myPosition.y + screensize.height/ 2.0f)**this>getScale;
float offy = ynext~~ this->getPositionY;
offy**= offsety;
ynext = this~~>getPositionY()+offy;

and zoom:
float z = this~~>getScale() - 0.002;
if(z <= 0.3) z = 0.3;

Zoom is OK, Move is OK but zoom + move is bad.


if im not mistaken, you are saying the camera is bad because it sticks to the target too hard, you will like to smooth it out right?

in this case, you can try lerp :

which in psuedo code is like this

setPosition((targetPosition - currentCameraPosition)*deltaTime+currentCameraPosition)