달력

10

« 2024/10 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
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 :)


:
Posted by netkorea