2010. 9. 5. 04:57
Setting cocos2D camera position using CCFollow 개발 - iPhone/개발 Tip2010. 9. 5. 04:57
http://snipplr.com/view/39706/setting-cocos2d-camera-position-using-ccfollow/
-
-(void)setPlayerPosition:(CGPoint)position {
-
CGPoint tileCoord = [self tileCoordForPosition:position];
-
int tileGid = [_meta tileGIDAt:tileCoord];
-
if (tileGid) {
-
if (properties) {
-
if (collision && [collision compare:@"True"] == NSOrderedSame) {
-
return;
-
}
-
if (collectable && [collectable compare:@"True"] == NSOrderedSame) {
-
[_meta removeTileAt:tileCoord];
-
[_foreground removeTileAt:tileCoord];
-
self.numCollected++;
-
[_hud numCollectedChanged:_numCollected];
-
}
-
}
-
}
-
-
ccTime moveDuration = 0.3;
-
id playerMove = [CCMoveTo actionWithDuration:moveDuration position:position];
-
id cameraMove = [CCFollow actionWithTarget:_player worldBoundary:CGRectMake(0, 0, (_tileMap.mapSize.width * _tileMap.tileSize.width), (_tileMap.mapSize.height * _tileMap.mapSize.height))];
-
[_player runAction:playerMove];
-
-
[self runAction:cameraMove];
-
-
}
'개발 - iPhone > 개발 Tip' 카테고리의 다른 글
UIPinchGestureRecognizer 실시간 이미지 resize (0) | 2010.09.28 |
---|---|
iPhone Keychain Access (0) | 2010.09.09 |
NSZombieEnabled (0) | 2010.08.06 |
소스 코드를 웹페이지에 삽입할 때 유용한 사이트 (0) | 2010.07.26 |
UITabBarController의 UINavigationController에서 하위에서 TabBar 숨기기 (0) | 2010.07.22 |