2013-11-27 3 views

답변

0

재정의 방법을 이미 터치에 이동할 수 있습니다,하지만 난 tiledmap을 시뮬레이션해야합니다

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

을 다음이 메시지를받을 때, 단지와 위치를 확인 :

//Grid of 20x20 pixels, with entire grid starting at 0,0 
static const CGFloat GridSize = 20; 

int gridColumn = (int)(location.x/GridSize); //we can lose the precision here 
int gridRow = (int)(location.y/GridSize); //we can lose the precision here 

node.position = CGPointMake(gridColumn*GridSize, gridRow*GridSize); 
012 : 당신은 당신의 위치를 ​​일단

UITouch *touch = [touches anyObject]; 
if(touch){// 
    CGPoint location = [touch locationInNode:self]; 

    .. moving code here 
} 

은 그냥 터치 내에 현재있는 그리드 항목을 기반으로 이동

물론 SKAction을 사용하여 이동을 애니메이션 할 수 있지만 터치를 추적하는 경우 실시간으로 원할 것입니다.

관련 문제