2D Toolkit Forum

2D Toolkit => Support => Topic started by: kliqingk on May 23, 2013, 03:30:02 am

Title: About Destorying tk2dAnimatedSprite
Post by: kliqingk on May 23, 2013, 03:30:02 am
Hey guys:
I have a problem. Please help.
I created a prefab using a tk2dAnimatedSprite. Then I created a instance like this:

tk2dAnimatedSprite temp = Instantiate(prefab, new Vector3(0,0,0), Quaternion.identity) as tk2dAnimatedSprite;
Destory(temp);

But the instance didn't destoryed. It still showed in the Hierarchy View.

I did another test. I created a prefab using a Cube.Then Coding like this:
GameObject temp = Instantiate(cubePrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject ;
Destory(temp);

The cub destoyed. It didn't show in the Hierarchy View.

How did I destoy a tk2dAnimatedSprite instance?
Title: Re: About Destorying tk2dAnimatedSprite
Post by: unikronsoftware on May 23, 2013, 10:17:15 am
You should always destroy the gameobject. This applies to all Unity objects.
so...
Destroy(temp.gameObject); will destroy the game object the sprite is attached to.
Title: Re: About Destorying tk2dAnimatedSprite
Post by: kliqingk on May 24, 2013, 06:38:16 am
Thank you for helping me. ;D ;D