2010. 9. 28. 15:04
cocos2d - CCTileMapAtlas | gaps | artifacts | black lines | flicker | v0.99.0rc 개발 - iPhone/개발 Tip2010. 9. 28. 15:04
http://www.cocos2d-iphone.org/forum/topic/4219
I decided to use a category to work-around this issue. Create a class called "CCMoveTo+RoundedUpdate" and add this code:
CCMoveTo+RoundedUpdate.h
//
// CCMoveTo+RoundedUpdate.h
//
// Category to rounded move any object and avoid gaps in tilemap.
// --> Overrides "update" code from CCIntervalAction.m
//
// Created by Markus Barta on 09.02.10.
//
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface CCMoveTo (RoundedUpdate)
@end
CCMoveTo+RoundedUpdate.m
//
// CCMoveTo+RoundedUpdate.m
//
// Created by Markus Barta on 09.02.10.
//
#import "CCMoveTo+RoundedUpdate.h"
@implementation CCMoveTo (RoundedUpdate)
-(void) update: (ccTime) t
{
//NSLog(@"Using category CCMoveTo+RoundedUpdate for movement -> rounded setPosition!");
[target setPosition: ccp( round(startPosition.x + delta.x * t ), round(startPosition.y + delta.y * t ) )]; //Setting to a rounded pos avoids gaps in tilemap!
}
@end
Just add those two files to your project and compile. The gaps should be gone :)
'개발 - iPhone > 개발 Tip' 카테고리의 다른 글
NSLog 개선 관련 팁들 (0) | 2010.10.13 |
---|---|
Update Incoming to my Gesture Detection Class (0) | 2010.10.01 |
cocos2d - Isometric map tile position, detect edges (0) | 2010.09.28 |
UIPinchGestureRecognizer 실시간 이미지 resize (0) | 2010.09.28 |
iPhone Keychain Access (0) | 2010.09.09 |