我一直试图让我的场景跟随我的玩家精灵,但由于某种原因它没有跟随。谁能解释为什么?我试过以下教程,但没有运气。这是我当前的代码:
[self setViewpointCenter:Player.position];
-(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, (theMap.mapSize.width * theMap.tileSize.width) - winSize.width / 2);
y = MIN(y, (theMap.mapSize.height * theMap.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;
}