Hey!
I'm trying to pool an AnimationSequence view objects. Ones creating new object to the pool, only one object (the last that was created) is actually having the view. It's like it's overriding the view of the others.
So I found out that I need to clone the view of each one, but couldn't understand how.
Here's what I'm doing:
Creating the pool object:
blockPool = new Box2DObjectPool(Blocker, { width:50,height:50, myState:this, view:new AnimationSequence(main.assetManager.getTextureAtlas("trees"), ["tree1", "tree2", "tree3", "tree4"], "tree1") } ); addPoolObject(blockPool); blockPool.initializePool();
Buidling some objects:
private function createBlockers():void { var b:Blocker; for (var i:uint = 0; i < 10; i++) b = blockPool.get( { x:100, y:200*i } ).data; }
Here I'm trying to clone the view, but getting an error:
override public function handleArtReady(citrusArt:ICitrusArt):void { view = AnimationSequence(view).clone(); super.handleArtReady(citrusArt); }
And this is the error I'm getting:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at citrus.view.starlingview::AnimationSequence/destroy()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\view\starlingview\AnimationSequence.as:172] at citrus.view.starlingview::StarlingArt/destroy()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\view\starlingview\StarlingArt.as:143] at citrus.view.starlingview::StarlingArt/set view()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\view\starlingview\StarlingArt.as:246] at citrus.view.starlingview::StarlingArt/update()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\view\starlingview\StarlingArt.as:450] at citrus.objects::Box2DObjectPool/_dispose()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\objects\Box2DObjectPool.as:85] at citrus.datastructures::PoolObject/increasePoolSize()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\datastructures\PoolObject.as:110] at citrus.datastructures::PoolObject/get()[C:\Users\Aymeric\Workspace\Flash\Libraries\Citrus-Engine\src\citrus\datastructures\PoolObject.as:136]