I was just wondering if tagged images can occupy memory/locations (I'm not sure what to call them so i call them memory/locations)...
The code below is used to find matches and then removes them from view when they are 3 or more in a row/column. The thing is though that it seems that the if statements only works once. Once they have been used they stop finding the matches.
Is there a way of "releasing" the occupied if statements or is there another way of doing this?
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;
}
}
}
No, they don't take up any memory. They are assigned only to be identified uniquely in its parent.
精彩评论