読んでくれてありがとう!
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint location = [[CCDirector sharedDirector] convertToGL: [touch locationInView:touch.view]];
CGRect myRect = CGRectMake(100, 120, 75, 113);
int tjx = sprite.position.x;
if(CGRectContainsPoint(myRect, location)) {
tjx ++;
}
}
何らかの理由でccTouchesEnded
、「スプライト」にアクセスできません。私も
CGRectMake
そのように使用しようとしました:
CGRectMake( sprite.position.x, sprite.position.y, sprite.contentSize.Width, sprite.contentSize.Height)
しかし、スプライトの位置や高さにアクセスできませんでした。init メソッドで宣言され、子に追加されると、宣言されていない「スプライト」が取得され続けます。
助けてください!!ここで本当に単純なものが欠けていると確信しています。