// 매우 확률이 높은 실수 ... 충돌이 작동하면 드래그 타일이 TargetNodeCatagoryT1에 도달하면 히트 객체에 BOOL을 설정하는 방법은?SKPhysics 노드와 어떻게 BOOL을 수정하여 객체를
if (firstBody.categoryBitMask == DragTileCategory &&
secondBody.categoryBitMask == TargetNodeCatagoryT1){
TargetNode *hitNode = (TargetNode *) secondBody.node;
hitNode.hasHitT1 = YES; <<this crashes app
but I wish to send BOOl back...
}
에러 로그 : 종단 앱 의한 캐치되지 않는 예외 'NSInvalidArgumentException'이유로 '- [SKSpriteNode setHasHitT1는 :] : 미정 선택기 인스턴스
Thank's Knight0fDragon You are right, the "hitNode" are SKSpriteNodes
nested within the TargetNode class - each TargetClass has 3 targets,
BOOLS are declared in .h and synthesised in .m
@interface TargetNode : SKNode
BOOL hasHitTarget1;
BOOL hasHitTarget2;
BOOL hasHitTTarget3;
//later
@property (nonatomic,assign) BOOL hasHitTarget1;
@property (nonatomic,assign) BOOL hasHitTarget2;
@property (nonatomic,assign) BOOL hasHitTarget3;
@implementation TargetNode
@synthesize hasHitTarget1,hasHitTarget2,hasHitTarget3;
-(id)initWithImageNamed:(NSString*)imageName labelText:(NSString*)labelText
other stuff here....then
hasHitTarget1 = NO;
hasHitTarget2 = NO;
hasHitTarget3 = NO;
보내 작업 내용 : 물리학 첨부 레이블에 바디를 연결하고 싶습니다. e later later (physicsBody는 marker를 약간 닮았습니다. secondBody.node를 찾으면 텍스트를 바꿀 수 있었을 것입니다 ... 아마도 이것은 최선의 방법은 아니지만 제 목적을 위해 일했습니다 :)
physicsBody 예 T1label.physicsBody = SKPhysicsBody bodyWithRectangleOfSize 부착// ...
// 객체 secondBody
didMakeContact에서secondBody.categoryBitMask == TargetNodeCatagoryT1) {
//Convert second body into useable object
SKLabelNode *hitNode = (SKLabelNode *) secondBody.node;
//change text
hitNode.text [email protected]"test";
NSLog(@"TargetNode [email protected]%@",hitNode.name);
//Test type of object
NSLog(@"hitNode isMemberOfClass TargetNode: %@", [hitNode isMemberOfClass:[TargetNode class]] ? @"YES":@"NO");
NSLog(@"hitNode isMemberOfClass SKSpriteNode: %@", [hitNode isKindOfClass:[SKLabelNode class]] ? @"YES":@"NO");
}
,174 찾는
안녕 Knight0fDragon 실패하여 생성되지있어 결코 코드 위에 추가 TargetNode 클래스의 내부 BOOL이 작동하지 않습니다. 내가 실수 한 부분을 볼 수있는 추가 코드가있을 수 있습니다 ... – StackBuddy
whoa whoa whoa, targetnode가 physicscontactdelegate 인 이유는 무엇입니까? – Knight0fDragon
잘 알고 있고, 수정되었습니다. . (지금은 bool 용) – StackBuddy