Start a new topic

Dynamically creating and destroying drawables and animations

Dynamically creating and destroying drawables and animations

Hi Andreas,

Thanks for your quick response.
I'll try to add following clean up sequence.

Destroy groups
World.animationGr.destroy(); World.animationGr = null;

Destroy prop. animations (saved per group)
World.animations.destroy(); World.animations = null;

Drawables are removed from the cam:
World.trackables.drawables.removeCamDrawable(World.augm);

Drawables are destroyed:
World.augm.destroy(); World.augm = null;
Please also destroy AR.PropertyAnimations.

I recommend you to first destroy the Animations, right afterwards the PropertyAnimations and after all the Augmentations itself.

Best regards
Recently I started preparing a sample application for a project with wikitude.
I have multiple AR.Trackable2DObject instances, so I arranged them in an array.
I added some buttons (AR.ImageDrawable) for each trackable as augmentations.
Now I try to figure out the best way to manage for creating and clearing drawables and animations.

The AnimationGroup object is created with an array (propertyAnims) containing the AR.PropertyAnimation objects for each drawable.
World.animations = new AR.AnimationGroup(AR.CONST.ANIMATION_GROUP_TYPE.PARALLEL, propertyAnims);

The clearing is done this way:
Drawables are removed from the cam:
World.trackables.drawables.removeCamDrawable(World.augm);  

Drawables are destroyed:
World.augm.destroy();
World.augm = null;


Is it okay to destory the AR.AnimationGroup instance before the related drawables are destroyed?
I would add a function for that.

clear: function clearFn(ii) {
    if (World.animations) {    
        if (!World.animations.destroyed) {
          World.animations.destroy();
        }
        World.animations = null;
    }
}

Is it sufficient to destroy the AnimationGroup?
Are the related PropertyAnimation objects disposed too?
Should I destroy the group before I recreate it (e.g. for other drawables that are added dynamically to the cam)?

Thanks in advance!
Login or Signup to post a comment