0
내 아이폰 (시뮬레이터가 아님)에서 앱을 실행할 때 이상한 검은 색 선이지도 이동을 시작할 때만 나타납니다. 타일 맵 이동 코드는 다음과 같습니다.iphone 게임 프로그래밍 : tilemap 검은 선 문제
- (void)handlePanFrom:(UIPanGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan) {
CGPoint touchLocation = [recognizer locationInView:recognizer.view];
touchLocation = [[CCDirector sharedDirector] convertToGL:touchLocation];
touchLocation = [self convertToNodeSpace:touchLocation];
} else if (recognizer.state == UIGestureRecognizerStateChanged) {
CGPoint translation = [recognizer translationInView:recognizer.view];
translation = ccp(translation.x, -translation.y);
CGPoint newPos = ccpAdd(self.position, translation);
self.position = [self boundLayerPos:newPos];
[recognizer setTranslation:CGPointZero inView:recognizer.view];
} else if (recognizer.state == UIGestureRecognizerStateEnded) {
float scrollDuration = 0.2;
CGPoint velocity = [recognizer velocityInView:recognizer.view];
CGPoint newPos = ccpAdd(self.position, ccpMult(ccp(velocity.x, velocity.y * -1), scrollDuration));
newPos = [self boundLayerPos:newPos];
[self stopAllActions];
CCMoveTo *moveTo = [CCMoveTo actionWithDuration:scrollDuration position:newPos];
[self runAction:[CCEaseOut actionWithAction:moveTo rate:1]];
}
}
나는 멍청하다. 나는 그 방법을 이해하지 못한다. – hugo411
@ the1nz4ne : 그럼 내가 제안한 두 번째 방법을 고수하라. 각 타일의 수명이 시작된 곳을 기억하고 처음에는 0 인 오프셋 누산기를 유지하십시오. 이동 이벤트가 등록 될 때마다 이동을 누적기에 추가하고 각 타일을 원래 위치와 누적기를 더한 값으로 설정하십시오. –