5
« on: February 12, 2012, 10:14:35 pm »
Hi
i have 1.56final
your example instantiates a sprite
my sprite is already instantiated.
I can find it as a game object
GameObject myBackground = GameObject.Find("spBackground");
how do i find it as a tk2dSprite?
What is the equivalent of this?
tk2dSprite myBackground=tk2dSprite.Find("spBackground");
so that i may expose the functions in question.
EDIT this is your code:
************************************************
// position first sprite at 100, 245, and 10 units away from the camera
sprite.transform.position = cam.ScreenToWorldPoint(new Vector3(100, 245, 10));
GameObject newSprite = GameObject.Instantiate(sprite.gameObject) as GameObject;
// get untrimmed bounds of this object
Bounds bounds = sprite.GetUntrimmedBounds();
// you can do this if the objects have the same dimensions
newSprite.transform.position += new Vector3(bounds.extents.x * 2.0f, 0, 0);
// but really what you need is
//Vector3 secondBounds = newSprite.sprite.GetUntrimmedBounds();
//newSprite.transform.position += new Vector3(bounds.extents.x + secondBounds.extents.x, 0, 0);
*****************************************
"newSprite" is clearly a GameObject. The lines after the (//but really) imply
that GetUntrimmedBounds() returns a Vector3 but I get an error
Also what is "newSprite.sprite" refferring to? sprite is not a property of GameObject.
Thanks
Jerry