저는이 문제에 조금 어려움을 겪었습니다. 내가 만들려고 노력하는 개체에 대한 여러 클래스를 피하기 위해 노력하고 있어요. 기본적으로 나는 letter 속성을 가진 'Letter'클래스를 가지고 있습니다. 개체를 초기화 할 때 A, B, C로 문자 유형을 설정합니다 ...이 작업을 모두 반복하고 있습니다. 모든게 잘된 것 같습니다.Cocos2D ccTouchesMoved Sprites and Objects
문제점은 내가 유형 A 또는 B 등의 Letter 객체를 움직이는 지 알고 싶다면 ccTouchesMoved 이벤트를 발생시키는 것입니다.이 것을 파악할 수 없습니다. 여기
내가 뭐하는 거지 보여주기 위해 일부 조각입니다문자 클래스
@implementation Letter
- (id)init {
if ((self = [super init])) {
gamePieceType = kLetterNotAssigned;
}
return self;
}
내 계층 초기화
for (int x=0; x < NUMBER_OF_ITEMS; x++) {
int randomX = random() % 1024;
[self createPuzzlePieceAtLocation:ccp(randomX, 600) withPiece:x];
}
createPuzzlePieceAtLocation 방법
- (void)createPuzzlePieceAtLocation:(CGPoint)location
withPiece:(int)tagValue {
switch (tagValue) {
case 1:
letterSprite = [[Letter alloc] initWithSpriteFrameName:@"upper_a.png"];
letterSprite.gamePieceType = kLetterA;
break;
...
}
[self createBodyAtLocation:location forSprite:letterSprite isBox:FALSE];
[sceneSpriteBatchNode addChild:letterSprite];
어떤 생각? ccTouchesMoved에서 touchLocation을 가져 오지만 어떻게 객체를 가져올 수 있습니까?