【问题标题】:CCSprite is not using the same texture idCCSprite 没有使用相同的纹理 ID
【发布时间】:2012-07-15 16:42:47
【问题描述】:

我创建了两个相同的CCSpriteBatchNode,分别添加不同的CCLayer。

CCSpriteBatchNode *mNode =      [param objectForKey:@"BatchNode"];

if (self =[super initWithTexture:mNode.texture rect:rect ])

{

    CCAnimation *walkAnim = [CCAnimation animationWithFrames:[[allFrameCache objectAtIndex:0] objectAtIndex:0] delay:frequencyFloat];
    CCAction* walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
    [self runAction:walkAction];

}

但它显示: 2012-07-15 11:18:27.389 SanGuo_[21379:707] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“CCSprite 未使用相同的纹理 ID”

我是新手,研究了半天,很郁闷,谁能帮帮我?

【问题讨论】:

    标签: cocos2d-iphone textures ccsprite


    【解决方案1】:

    CCSprite 没有使用相同的纹理 ID

    您只能将精灵添加到与精灵批处理节点使用相同纹理的精灵批处理节点。这是您尝试将精灵添加到纹理与批处理节点不同的批处理节点时遇到的错误。

    解决方案:确保精灵使用与批处理节点相同的纹理。

    【讨论】:

    • 非常感谢,我找到原因了,是想你说的,开始一个项目,我想到同名的批处理文件没问题,结果是原因,CCSpriteBatchNode* BatchNode = [CCSpriteBatchNode batchNodeWithFile:[NSString stringWithFormat:@"%@.png",name]] ; Sprite节点内的所有CCSpriteBatchNode都是0_0_0。巴布亚新几内亚,0 _0_1。巴布亚新几内亚,0 _0_2。 PNG……,但和照片不一样,无法识别。说了这么多,不知道表达意识了吗?再次感谢您!
    • 也许可以使用纹理图集?这听起来像它可以使用一个。查看 TexturePacker。
    猜你喜欢
    • 2013-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多