做塔防遊戲時出錯!在第二座塔殺死怪時出錯

            if(MonsterProp"AtkTarget"]]"hp"]<=0){ //怪物死亡
                TowersProp"tdtag"]].erase("AtkTarget"); //刪除塔的攻擊目標
                Monster.erase(Monster.find(mon)); 從容器中刪除怪物 (就是這兩句錯)
                this->removeChildByTag(BulletsProp"AtkTarget"]); 刪除怪物 (就是這兩句錯)
            }

malloc: *** error for object 0x78a2b400: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

this cocos2d::Ref * 0x78a2b400 0x78a2b400
_referenceCount unsigned int 0 0
_ID unsigned int 220 220
_luaID int 0 0
_scriptObject void * NULL 0x00000000

有沒有人!!!!!!!!

:6: :6: :6: :6: :6: :6: :6: :6: :6: :6: :6:

:8: :8: :8: :8: :8: :8: :8: :8: :8: :8: :12: :12: :12: :12: :12: :12: :12: :12:

這裡到底有多少人!!!!:3::3::3::3::3::3::3::3::3:

:2: :2: :2: :2: :2: :2: :2: :2:

这是你的问题,和Cocos2d-x,无人答是很正常的

好好!好好!好好!好好!好好!好好!好好!好好!

看起来是怪物结构被手动释放了两次,
“Monster.erase(Monster.find(mon)); 從容器中刪除怪物 (就是這兩句錯) ”
这一句是不是调用了怪物的释放呢. 你可以去写个log调试一下. 你怪物有独立的类就可以在析构里面写log 看调用了没有.

确认下两次删除的时候都还在不在,referenceCount 是0,应该是不存在了。

哦,多謝啊!!!我改方法了,死亡時先標為死亡,visible=false,等所有怪都死了再刪除,這樣沒事~