0
嗨我正在使用此代碼來滾動我的瓷磚地圖,什麼是實現視差滾動的最佳方式?我找到了一種方法,但是效果不好。 :(Parallax使用Sprite工具包滾動像舊學校snes遊戲
- (void)setViewpointCenter:(CGPoint)position {
NSInteger x = MAX(position.x, self.size.width/2);
NSInteger y = MAX(position.y, self.size.height/2);
x = MIN(x, (self.map.mapSize.width * self.map.tileSize.width) - self.size.width/2);
y = MIN(y, (self.map.mapSize.height * self.map.tileSize.height) - self.size.height/2);
CGPoint actualPosition = CGPointMake(x, y);
CGPoint centerOfView = CGPointMake(self.size.width/2, self.size.height/2);
CGPoint viewPoint = CGPointSubtract(centerOfView, actualPosition);
self.map.position = viewPoint;
}
謝謝大家的幫助!