Citrus对象的销毁有三种方式
// Inside a class which extends CitrusObject e.g. CitrusSprite, APhysicsObjects...
kill
=
true
;
// If you have an access to the variable of the object :
hero
.
kill
=
true
;
// Or within a State class (the previous code works too) :
remove
(
hero
);
cirtusEngine并不销毁游戏对象只是标记销毁,所以使用cirtusEngine最好使用对象池进行管理
cirtusEngine有自带的对象池citrus.datastructures.PoolObject
PoolObject继承自citrus.datastructures.DoublyLinkedList
这是一个双向链表。大家知道在频繁插入与删除的数据结构中,链表效率要比数组高得多。
使用方法也很简单
_poolObject = new PoolObject(NapePhysicsObject, 50, 5, true);
addPoolObject(_poolObject);
for (var i:uint = 0; i < 5; ++i)
_poolObject.create({x:i * 40 + 60, view:"crate.png"});
refreshPoolObjectArt(_poolObject);
对象池的销毁
_poolObject.disposeAll();