【问题标题】:Error [CCSprite visit]: message sent to deallocated instance错误 [CCSprite 访问]:消息发送到解除分配的实例
【发布时间】:2012-01-28 05:20:05
【问题描述】:

嗨,我在游戏中,我的游戏中有多个项目我有一个问题,当我一次又一次选择相同的项目时它会崩溃,但如果我选择不同的项目它仍然很好并且不会发生崩溃我启用 NSZombieEnabled 并得到这个错误,我不明白我保留我的每个精灵是什么意思,但错误是一样的,这是我得到的错误

-[CCSprite visit]: message sent to deallocated instance 0x5594c00

任何人都可以在这种情况下帮助我。我尝试了太多,但不明白我是 iphone 游戏开发的新手,所以请帮助我。

【问题讨论】:

    标签: iphone cocos2d-iphone xcode4.2


    【解决方案1】:

    也就是说,您的 CCSprite* 指针指向已释放的对象。这样你就可以得到这个:

    CCSprite *sprite = [[CCSprite alloc] initWithSomething:foo]; //reference counter is 1
    [sprite release]; //reference counter is 0. object is deallocated. But sprite is still pointing to the object
    [sprite visit]; // here you are trying to visit the deallocated sprite
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-11
      • 2013-06-04
      • 2012-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多