0
タグ付きの画像がメモリ/場所を占有できるかどうかは不思議に思っていました(私はそれらを呼び出すために何を呼び出すべきかわかりません)...タグ付き画像はメモリ/位置を占有していますか?
以下のコードは、それらが行/列の3つ以上であるときのビューからのそれら。事はif文が一度しか動作しないように思えますが。彼らが使用されると、彼らは試合を見つけるのをやめます。
占有されたif文を "解放"する方法はありますか、これを行う別の方法がありますか?
for(int y=0; y<HEIGHT-2; y++){
for(int x=0; x<WIDTH-2; x++){
//don't match empty squares
if(grid[x][y] == nil){
continue;
NSLog(@"continue");
}
if(x >= 2 && x <= WIDTH -2 && y >= 2 && y <= HEIGHT - 2) {
//Check to the right
if(grid[x+1][y].tag == grid[x][y].tag && grid[x+2][y].tag == grid[x][y].tag) {
NSLog(@"to the right");
grid[x][y].alpha = 0;
grid[x+1][y].alpha = 0;
grid[x+2][y].alpha = 0;
NSLog(@"Match to the right grid[x][y].tag %d",grid[x][y].tag);
NSLog(@"Match to the right grid[x+1][y].tag %d",grid[x+1][y].tag);
NSLog(@"Match to the right grid[x+2][y].tag %d",grid[x+2][y].tag);
}
//Check to the left
else if (grid[x-1][y].tag == grid[x][y].tag && grid[x-2][y].tag == grid[x][y].tag){
NSLog(@" to the left");
grid[x][y].alpha = 0;
grid[x+1][y].alpha = 0;
grid[x+2][y].alpha = 0;
NSLog(@"Match to the left grid[x][y].tag %d",grid[x][y].tag);
NSLog(@"Match to the left grid[x-1][y].tag %d",grid[x-1][y].tag);
NSLog(@"Match to the left grid[x-2][y].tag %d",grid[x-2][y].tag);
}
//Check up
else if(grid[x][y-1].tag == grid[x][y].tag && grid[x][y-2].tag == grid[x][y].tag){
NSLog(@"up");
grid[x][y].alpha = 0;
grid[x][y-1].alpha = 0;
grid[x][y-2].alpha = 0;
NSLog(@"Match up grid[x][y].tag %d",grid[x][y].tag);
NSLog(@"Match up grid[x][y-1].tag %d",grid[x][y-1].tag);
NSLog(@"Match up grid[x][y-2].tag %d",grid[x][y-2].tag);
}
//Check down
else if(grid[x][y+1].tag == grid[x][y].tag && grid[x][y+2].tag == grid[x][y].tag){
NSLog(@"down");
grid[x][y].alpha = 0;
grid[x][y+1].alpha = 0;
grid[x][y+2].alpha = 0;
NSLog(@"Match down grid[x][y].tag %d",grid[x][y].tag);
NSLog(@"Match down grid[x][y+1].tag %d",grid[x][y+1].tag);
NSLog(@"Match down grid[x][y+2].tag %d",grid[x][y+2].tag);
}
else{
GamePaused = NO;
}
}
}
それは私が思ったことです。私は私の問題について私が持っていた唯一の理論でした。つまり、if文が何度も使用されるのを防ぐのは何ですか?助言がありますか? – iphonedevonthemake