2010. 9. 28. 15:20
cocos2d - PinchZoomLayer Example App - like fieldrunners 개발 - iPhone/참조 사이트/글2010. 9. 28. 15:20
http://www.cocos2d-iphone.org/forum/topic/7843
I thought I'd go ahead and start a new thread for this...
This is an example project file I put together that handles pinchzoom, scroll, doubletap zoom, etc... feels alot like fieldrunners pinchzoom functionality.
The doubletap-zoom may need some adjustments but overall it works very well. If anyone improves it please share!
http://dl.dropbox.com/u/8990214/pinchzoom.zip
Enjoy
CGSize mapSize;
self.tileMap = [CCTMXTiledMap tiledMapWithTMXFile:@"TileMap.tmx"];
self.background = [_tileMap layerNamed:@"Background"];
self.isTouchEnabled = YES;
// had to do this because the tilemap is > than the iPhone screen size
mapSize = _tileMap.contentSize;
// create a base layer
CCColorLayer *base = [CCColorLayer layerWithColor:ccc4(139,139,139,255)];
base.position = ccp(0,0);
base.contentSize = mapSize;
[base addChild:_tileMap];
[self addChild: base z:0];
self.anchorPoint = CGPointZero;
base.anchorPoint = CGPointZero;
_tileMap.anchorPoint = CGPointZero;
// attach base layer to PinchZoomLayer
PinchZoomLayer *pZoom = [PinchZoomLayer initPinchZoom:base];
// zoom out all the way
[pZoom scaleToFit];
GameSceneHUD *HUD = [GameSceneHUD node];
HUD.anchorPoint = CGPointZero;
[self addChild:HUD z:10];
self.HUD = HUD;
'개발 - iPhone > 참조 사이트/글' 카테고리의 다른 글
Don’t use UITableViewController. Really. (0) | 2010.10.14 |
---|---|
cocos2d - Path Finding and Tile Maps- Sample App (0) | 2010.09.28 |
Jeff LaMarche 블로그: OpenGL ES 관련 참고 사이트 (0) | 2010.06.11 |
connect several iPhones using Gamekit via Bluetooth w/o GKPeerPickerController (0) | 2010.05.17 |
소개:아이폰 앱 광고에서 앱 이름과 아이콘의 중요성에 대한 글 (0) | 2010.05.17 |