Hello -
At the moment I have a camera attached to a physics body. The camera follows accordingly and as needed. However, I would like to expand the camera to apply a 'damping' or spring.
Camera movement directly applies a snap-to-center, but I'd like to integrate the damping to the camera.
Here is what I'm using -
-(void)setViewpointCenter:(CGPoint) position {
CGSize winSize = [[CCDirector sharedDirector] winSize];
int x = MAX(position.x, winSize.width / 2);
int y = MAX(position.y, winSize.height / 2);
x = MIN(x, (_tileMap.mapSize.width * _tileMap.tileSize.width)
- winSize.width / 2);
y = MIN(y, (_tileMap.mapSize.height * _tileMap.tileSize.height)
- winSize.height/2);
CGPoint actualPosition = ccp(x, y);
CGPoint centerOfView = ccp(winSize.width/2, winSize.height/2);
CGPoint viewPoint = ccpSub(centerOfView, actualPosition);
self.position = viewPoint;
}
This comes directly from How To Make A Tile Based Game with Cocos2D
Any help on this matter would be greatly appreciated.
Thanks in advance.