Hello
Guest
Home
Help
Search
Login
Register
2D Toolkit Forum
»
2D Toolkit
»
Support
»
Hiding a tk2dAnimatedSprite
« previous
next »
Print
Pages: [
1
]
Author
Topic: Hiding a tk2dAnimatedSprite (Read 7948 times)
arkanoid87
2D Toolkit
Newbie
Posts: 12
Hiding a tk2dAnimatedSprite
«
on:
June 19, 2012, 11:06:08 am »
Hello
I'm trying to hide a tk2dAnimatedSprite.
With tk2dSprite I can disable the renderer or the entire gameobject, but the same option seems not not available on animated sprites. Am I wrong?
Currently I'm hiding the object by moving it outside the view, is it the supposed way of hiding it?
Thank you
Logged
unikronsoftware
Administrator
Hero Member
Posts: 9709
Re: Hiding a tk2dAnimatedSprite
«
Reply #1 on:
June 19, 2012, 11:14:41 am »
You can just deactivate the game object.
sprite.gameObject.active = false;
Logged
arkanoid87
2D Toolkit
Newbie
Posts: 12
Re: Hiding a tk2dAnimatedSprite
«
Reply #2 on:
June 19, 2012, 11:25:33 am »
I've found out that I need at least one tk2dAnimatedSprite playing any animation to use renderer or gameobject toggle. If no animations are playing (no mesh update cycle I suppose) the toggle checkboxes won't work.
Logged
unikronsoftware
Administrator
Hero Member
Posts: 9709
Re: Hiding a tk2dAnimatedSprite
«
Reply #3 on:
June 19, 2012, 11:35:00 am »
Thats weird, you should be able to turn off the MeshRenderer no problem. Anyway, its much more efficient to disable the gameobject.
Logged
arkanoid87
2D Toolkit
Newbie
Posts: 12
Re: Hiding a tk2dAnimatedSprite
«
Reply #4 on:
June 19, 2012, 07:00:31 pm »
I've solved by enabling/disabling the gameobject only when starting animations.
my problem now is quite different, inside a coroutine I launch:
Code:
[Select]
myTk2dAnimatedSprite.gameObject.active = true;
myTk2dAnimatedSprite.Play( "myAnimationName" );
but during the following frame myTk2dAnimatedSprite.spriteID is shown and only the next frame myAnimationName displays the first frame. This makes the previous sprite flashing on screen for one frame.
Is there any provided solution for this or I should "yield return null" to skip one frame before enabling the gameobject?
thank you
Logged
unikronsoftware
Administrator
Hero Member
Posts: 9709
Re: Hiding a tk2dAnimatedSprite
«
Reply #5 on:
June 19, 2012, 11:37:42 pm »
I will be issuing a fix for this in the next release. Whats happening is that play doesn't update the frame itself, that happens in Update, but when you call it from a coroutine, Update only gets called in the next frame.
Logged
Print
Pages: [
1
]
« previous
next »
2D Toolkit Forum
»
2D Toolkit
»
Support
»
Hiding a tk2dAnimatedSprite