-1
我有一個8x8矩陣的字母遊戲,當我將觸摸移動到標籤中,標籤值重複,如何克服這個問題,字母在8x8中隨機位置矩陣。如何從CCLabelTTF精靈中獲取獨特的字母當觸摸移動到cocos2d中
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch=[touches anyObject];
CGPoint newlocation=[touch locationInView:[touch view]];
newlocation=[[CCDirector sharedDirector] convertToGL:newlocation];
for (int i=0; i<GRID_WIDTH; i++) {
for (int j=0; j<GRID_HEIGHT; j++) {
if (CGRectContainsPoint([grid[i][j].letter boundingBox],newlocation)) {
CCLOG(@"letters %@",[grid[i][j].letter string]);
[letterarray addObject:[grid[i][j].letter string]];
}
}
}
}
什麼似乎是問題?請澄清你的問題。 – YvesLeBorg
我通過邊框移動時觸摸,這樣得到重複的字母:乙 乙 乙 W¯¯ W¯¯ W¯¯ W¯¯ W¯¯ W¯¯ W¯¯ W¯¯ W¯¯ 我 我 –