1
我最近做的麻煩:洗牌的隨機化
- 我創建了我導入所有我的8個 圖像的randomization_array ....
- 我創建了8個圖像的數據的plist(NSDictionary的)
然後,
NSMutableArray *randomization_array = [[NSMutableArray alloc] init]; [randomization_array addObjectsFromArray:array]; [randomization_array addObjectsFromArray:array]; NSMutableArray *shuffled_array = [[NSMutableArray alloc] initWithArray:randomization_array]; for(int x=0;x<[randomization_array count]/2;x++) { int random = arc4random_uniform([randomization_array count]/2); int destination = random *2; NSDictionary *origin_dict = [randomization_array objectAtIndex:x]; NSDictionary *destionation_dict= [randomization_array objectAtIndex:destination]; [shuffled_array insertObject:origin_dict atIndex:destination]; [shuffled_array insertObject:destionation_dict atIndex:x]; }
我使它2組隨機圖像....
我的問題,我應該怎麼做只有兩個組圖片....每次 我從新圖像應該進來對8 + 8 = 16 ....期待 的代碼和Frens
這是一個非常好的鏈接完全符合我的要求... – 2011-12-31 07:49:26