我必须上课、生存和 HUDLayer。
在我的 HUDLayer 中,我有一个 SneakyButton,使用该按钮我调用 Survival.m 中名为 -(void)fire 的方法,但是当我调用该方法时,我收到错误消息 CCSpriteBatchNode: resizing TextureAtlascapacity from
我知道该方法正在被调用,因为我使用 NSLog() 检查了该方法
-(void)fire {
NSLog(@"Fire");
}
在我的日志中,它返回 Fire 以及那个奇怪的警告。 当我收到警告时,fps 下降到 30 左右。有人有什么建议吗?
最佳答案
这是您可以在 cocos2d 源代码中找到有关调整纹理图集大小的内容:
// if we're going beyond the current CCTextureAtlas's capacity,
// all the previously initialized sprites will need to redo their texture coords
// this is likely computationally expensive
This is the explication正在发生的事情:
The internal array of sprites are increasing because your are adding more sprites to the batch (the log is there just to let you know on debug versions).
子节点也计入达到 Sprite 容量的限制。
您可以尝试为批处理节点设置更高的限制:
[CCSpriteBatchNode batchNodeWithFile:@"myAtlas.png" capacity:100]; // capacity for 100 objects
减少这种情况发生的频率。
关于ios - Cocos2D - 调用另一个类中的方法时出现奇怪的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14546469/