标记的图像是否占用内存/位置?

时间:2011-05-11 06:24:19

标签: iphone cocoa-touch xcode

我只是想知道标记的图像是否可以占用内存/位置(我不知道该怎么称呼它们,所以我称之为内存/位置)......

以下代码用于查找匹配项,然后在行/列中为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;
    }
}

}

1 个答案:

答案 0 :(得分:0)

不,他们不占用任何记忆。它们仅被指定为在其父级中唯一标识。