我正在使用通用池将 Sprite 添加到 AndEngine 中的场景,间隔为每 1 秒。
当添加 Sprite 时,我会在它们与某些对象碰撞时回收它们。
我不断收到此错误
12-27 12:45:07.890: E/AndEngine(25299): More items recycled than obtained!
12-27 12:45:07.890: E/AndEngine(25299): java.lang.Exception
12-27 12:45:07.890: E/AndEngine(25299): at org.anddev.andengine.util.Debug.e(Debug.java:117)
12-27 12:45:07.890: E/AndEngine(25299): at org.anddev.andengine.util.Debug.e(Debug.java:107)
12-27 12:45:07.890: E/AndEngine(25299): at org.anddev.andengine.util.pool.GenericPool.recyclePoolItem(GenericPool.java:127)
12-27 12:45:07.890: E/AndEngine(25299): at com.fttech.hungryhippos.Arcade_MainGame$1.onUpdate(Arcade_MainGame.java:738)
它不会导致强制关闭,但我确实担心它会在以后引起问题。
这是我应该担心的错误吗?
这也是我如何回收我的元素..
@Override
protected void onHandleRecycleItem(final Sprite pItem) {
pItem.setVisible(false);
pItem.setIgnoreUpdate(true);
}
最佳答案
来自 AndEngine 论坛上的 herpderp:
It means what it says. In the GenericPool source there's a member variable that increments when obtainPoolItem is called, and decrements when recyclePoolItem is called. If it falls below zero - in other words, if recyclePoolItem is called more times than obtainPoolItem is called - then you get that error message.
There's no simple fix for this problem. You just have to look over your code, specifically at where you recycle and obtain pool items, and try to figure out why recyclePoolItem would be called too often.
关于java - 通用池 "More Items Recycled than obtained"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8647673/