나는 몇 개의 출구 포인트를 가지고 bool
값을 반환하는 방법을 가지고있다. 그러나 제대로 작동하지 않는 것, 그래서 내가 자동 변수를 YES 값을 반환하는 보려면 자동 중단 점을 설정하고 싶습니다, 그래서 모든 변수 및 계산 디버거에서 확인할 수 있습니다. YES
값이 반환 될 때마다 디버거를 중지하고 싶습니다.메서드가 특정 값을 반환 할 때 "스마트"중단 점을 Xcode에 설정하는 방법은 무엇입니까?
비슷한 스마트 브레이크 포인트를 objc_exception_throw
으로 설정 했으므로 가능하다는 것을 알고 있습니다. 그 방법은 확실하지 않습니다.
가 (여기서 사람, 당신은 예외 중단 점을 설정할 수있는 방법 데 도움이 : 중단 점 창에서을 (실행 ->보기 -> 중단 점) "위치"로 "브레이크 포인트"로 objc_exception_throw
입력 libobjc.A.dylib
)
편집 :이 방법은
- (void)update:(ccTime)delta {
if ([self collisionOccured]) {
NSLog(@"A collision occured");
}
}
를 통해이라고
- (BOOL)collisionOccured {
// Assumption: helicopter is of square shape (collision calculated by radius), walls are rectangles
// This approach is based on the solution seen here: http://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection/402010#402010
float helicopterImageWidth = [helicopter texture].contentSize.width;
float wallImageWidth = [[walls lastObject] texture].contentSize.width;
float wallImageHeight = [[walls lastObject] texture].contentSize.height;
float helicopterCollisionRadius = helicopterImageWidth * 0.4f;
CGPoint helicopterPosition = helicopter.position;
int numWalls = [walls count];
for (int i = 0; i < numWalls; i++) {
CCSprite *wall = [walls objectAtIndex:i];
if ([wall numberOfRunningActions] == 0) {
// The wall is not moving, we can skip checking it.
continue;
}
CGPoint wallPosition = wall.position;
float helicopterDistanceX = abs(helicopterPosition.x - wallPosition.x - wallImageWidth/2);
float helicopterDistanceY = abs(helicopterPosition.y - wallPosition.y - wallImageHeight/2);
if (helicopterDistanceX > (wallImageWidth/2 + helicopterCollisionRadius)) { return NO; }
if (helicopterDistanceY > (wallImageHeight/2 + helicopterCollisionRadius)) { return NO; }
if (helicopterDistanceX <= (wallImageWidth/2)) { return YES; }
if (helicopterDistanceY <= (wallImageHeight/2)) { return YES; }
float cornerDistance_sq = powf((helicopterDistanceX - wallImageWidth/2), 2) +
powf((helicopterDistanceY - wallImageHeight/2), 2);
return (cornerDistance_sq <= powf(helicopterCollisionRadius, 2));
}
// this should not occur
return NO;
}
: 내가하고 싶은 특정 코드는 그것을 사용하는
문제는 업데이트 방법이 인수로 delta
(시간이 경과 됨)이 걸리므로 프레임별로 어떤 일이 발생하는지 확인할 수 없습니다. 실행을 계속할 때마다 다른 장면이 표시됩니다. 당신은 그냥 그렇지 않으면 ret
에 시계 포인트를 설정할 수 있습니다
- (BOOL)someMethod {
BOOL ret = NO;
if (something) {
ret = YES;
} else if (something_else) {
ret = YES;
}
// ... and so on
return ret;
}
당신은 : 로컬 반환 변수를 사용하는 경우
Objective-C에서 Run-> Stop을 통해 objc_exception_throw 중단 점을 토글 할 수도 있습니다. 예외 –