Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone中的图像替换_Iphone_Image_Replace_Cocos2d Iphone - Fatal编程技术网

iphone中的图像替换

iphone中的图像替换,iphone,image,replace,cocos2d-iphone,Iphone,Image,Replace,Cocos2d Iphone,我使用下面的代码,然后检查rect,添加了一些sprite 我想用另一个精灵替换这些精灵。你能帮我提供代码吗 替换这些随机图像。问题是要替换的图像也被拍摄 随机地 yp = 40; //CCSprite *spr; movableSprites = [[NSMutableArray alloc] init]; for(int m=0; m<4; m++) { do {

我使用下面的代码,然后检查rect,添加了一些sprite 我想用另一个精灵替换这些精灵。你能帮我提供代码吗 替换这些随机图像。问题是要替换的图像也被拍摄 随机地

             yp = 40;
    //CCSprite *spr;

    movableSprites = [[NSMutableArray alloc] init];

    for(int m=0; m<4; m++)
    {               
        do
        {
            i = 'a';
            //NSLog(@"valueeeeeeeee %d",i);
            next = arc4random()%maxalphabets;
            //NSLog(@"valueeeeeeeeenexttttt %d",next);
            i+=next;
            //NSLog(@"valueeeeeeeee %d",i);

            spr = (CCSprite*)[self getChildByTag:i];//checks if found alreadyyyyyy
            NSLog(@"Strrrrrrrr is:%@",spr);
        }while(spr);

        spNameStr = [NSString stringWithFormat:@"%c3.png",i];
        NSLog(@"tagggg %d",i);
        NSLog(@"spNameStr is:%@",spNameStr);
        spr = [CCSprite spriteWithFile:spNameStr ];
        spr.tag = i;
        //NSLog(@"tagiiiiii %d",i);
        spr.position = ccp(60,yp);  
        [self addChild:spr z:2];
        [movableSprites addObject:spr];
        yp+=spr.contentSize.height+35;
    }

    yp = 40;

    NSMutableArray *answerimagesCopy = [NSMutableArray arrayWithArray:movableSprites];
    NSLog(@"answer image copy elements areeeee %@",answerimagesCopy);
    for(k = 0; k < movableSprites.count; ++k) 
    {
        NSLog(@"inside forrrr");
        int j=arc4random()%([answerimagesCopy count]);
        NSLog(@"valueee of jjjjjjjj %d",j);
        CCSprite *ansimage = [answerimagesCopy objectAtIndex:j];
        //NSLog(@"................ %@",ansimage);
        p=ansimage.tag;
        NSLog(@"tagg..... %d",p);
        [answerimagesCopy removeObjectAtIndex:j];
        //NSLog(@"tagg..... %d",j);


        spNameStr = [NSString stringWithFormat:@"%c4.png",p];   
        NSLog(@"spNameStr is:%@",spNameStr);
        //NSLog(@"tagggg %d",j);
        spr = [CCSprite spriteWithFile:spNameStr ];
        spr.tag = p+100;
        spr.position = ccp(260,yp);
        [self addChild:spr z:1];
        yp+=spr.contentSize.height+35;
    }
yp=40;
//CCSprite*spr;
movableSprites=[[NSMutableArray alloc]init];

对于(int m=0;m我已使用精灵工作表完成此操作。如果您可以创建精灵工作表,然后将该精灵工作表分配给CCSpriteBatchNode的对象,如

$CCSpriteBatchNod*m_陨石prites=[CCSpriteBatchNode batchNodeWithFile:@“Meteo.pvr.ccz”]

然后加载plist

$[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@“Meteo.plist”]

然后使用精灵帧将图像指定给精灵

$m_MeteoriteSprites=[CCSpriteBatchNode batchNodeWithFile:@“Meteo.pvr.ccz”]

我用Texturepacker做雪碧床单

希望这对你有帮助