Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.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
iphonecocos2d-SpriteSheet cococos2d(太混乱了…)_Iphone_Performance_Graphics_Cocos2d Iphone - Fatal编程技术网

iphonecocos2d-SpriteSheet cococos2d(太混乱了…)

iphonecocos2d-SpriteSheet cococos2d(太混乱了…),iphone,performance,graphics,cocos2d-iphone,Iphone,Performance,Graphics,Cocos2d Iphone,我从Cocos2D板上得到了0个响应,所以我想我可以试试这里 嗯。我正在为这个扯头发。昨天晚上,我对我的代码进行了一次完整的重新整理,希望能解决一些iphone4的帧速率问题。我提前创建了精灵,而不是在更新方法期间进行一些创建。我现在只根据需要在update方法中将它们添加到spritesheet中 然而,这并没有解决问题。出于好奇,我改变了一件事。我的主精灵表是2048x2048,包含24帧和一个静态帧。我曾经从使用SpriteWithPriteFrameName生成的帧中提取静态图像。相反,

我从Cocos2D板上得到了0个响应,所以我想我可以试试这里

嗯。我正在为这个扯头发。昨天晚上,我对我的代码进行了一次完整的重新整理,希望能解决一些iphone4的帧速率问题。我提前创建了精灵,而不是在更新方法期间进行一些创建。我现在只根据需要在update方法中将它们添加到spritesheet中

然而,这并没有解决问题。出于好奇,我改变了一件事。我的主精灵表是2048x2048,包含24帧和一个静态帧。我曾经从使用SpriteWithPriteFrameName生成的帧中提取静态图像。相反,我只是决定为它制作另一个图像文件,并从中创建它。帧率问题基本上解决了…我不明白为什么。我以为纹理已经在记忆中了?我的代码有什么问题吗

circleSpriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"spritesheetbase.png"];

    //Load Note Animations
    for (int i = 0; i < 25; i++)
    {
            int x = i % 5;
     int y = i / 5;

     CCSpriteFrame* frame = [[CCSpriteFrame alloc] initWithTexture:circleSpriteSheet.textureAtlas.texture rect:CGRectMake(x * 200, y * 200, 200, 200)];
     [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFrame:frame name:[NSString stringWithFormat:@"noteFrame%d.png", i]];
     [frame release];
    }

    CCSprite *s = [CCSprite spriteWithFile:@"staticRing.png"];
    //CCSprite *s = [CCSprite spriteWithSpriteFrameName:@"noteFrame0.png"]; <--- Old way I used to create it
circleSpriteSheet=[CCSpriteBatchNode batchNodeWithFile:@“spritesheetbase.png”];
//加载注释动画
对于(int i=0;i<25;i++)
{
int x=i%5;
int y=i/5;
CCSpriteFrame*frame=[[CCSpriteFrame alloc]initWithTexture:CirclePriteSheet.textureAtlas.texture rect:CGRectMake(x*200,y*200200200)];
[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFrame:帧名称:[NSString stringWithFormat:@“noteFrame%d.png”,i]];
[帧释放];
}
CCSprite*s=[CCSprite spriteWithFile:@“staticRing.png”];

//CCSprite*s=[CCSprite spritewithpriteframename:@“noteFrame0.png”] 我发现在调试模式下构建/运行时存在性能问题。尝试在发布模式下构建/运行,看看这是否能解决帧速率问题。这解决了此帖子下的类似帧速率问题:


我希望它也能为你解决这个问题

我遇到了帧率问题。我很好奇为什么SpriteWithPriteFrameName会在纹理和帧已经存在于内存中的情况下导致这样的延迟。我做精灵表的方式有问题吗?顺便说一句,这是最新的Cocos2d版本,我想你只是在缓存东西而不是使用它,然后画一些没有缓存的东西。但我可能错了。当我在更新方法中实际运行带有动作的动画时,这些缓存帧正在其他地方使用。我只是将静态帧添加到缓存中并从中获取它。