[cocos2d-iPhone] cocos2d-iPhone中隐藏的洗牌程序

shuffle

随机打乱一个整数数组的排列:

在"CCActionTiledGrid.m"文件中

-(void)shuffle:(NSUInteger*)array count:(NSUInteger)len
{
    NSInteger i;
    for( i = len - 1; i >= 0; i-- )
    {
        NSInteger j = rand() % (i+1);
        NSUInteger v = array[i];
        array[i] = array[j];
        array[j] = v;
    }
}

 

posted @ 2013-07-02 16:01  allo_shuang  阅读(122)  评论(0编辑  收藏  举报