Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void) setCenterofScreen:(CGPoint) position{
- CGSize screenSize = [[CCDirector sharedDirector]winSize];
- float x = MAX(position.x,screenSize.width/2);
- float y = MAX(position.y, screenSize.height/2);
- x = MIN(x, theMap.mapSize.width * theMap.tileSize.width - screenSize/2);
- y = MIN(y, theMap.mapSize.height * theMap.tileSize.height - screenSize/2);
- CGPoint goodPoint = ccp(x,y);
- CGPoint centerOfScreen = ccpAdd(screenSize.width/2, screenSize.height/2);
- CGPoint difference = ccpSub(centerOfScreen, goodPoint);
- self.position = difference;
Add Comment
Please, Sign In to add comment