2D Toolkit > Support

tk2dButton removes tk2dSprite

(1/2) > >>

aphexyuri:
Hi,

I encountered a strange behavior...I have a tk2dSprite with a tk2dButton behavior attached to it. I've debugged and the message destination/function is getting called, but as soon as I click on the sprite, the sprite becomes invisible - it still registers the clicks after that, but it's hidden.

Is there something I'm missing or doing wrong?

Thanks,
Yuri

unikronsoftware:
This sounds like the button up sprite is incorrect - could you check if the button reappears when you click down on it again (while being held down). also, at which point does it disappear, is it when as soon as it registers a click?

aphexyuri:
Ha! Yes, that was exactly what it was. If I add the button_up / _down values it show a sprite. The only problem is...I'm assigning my sprite dynamically at runtime, and separate instances of the sprites will have different names/ids.

I'm attaching my icon class...is there perhaps a way to set the up/down properties dynamically?

Thanks,
Yuri

aphexyuri:
Btw...you'll see that to force the Sprite to show a certain spite, I set the spriteId in the Update method.

unikronsoftware:
To set them dynamically, simply create a setter like this:


--- Code: --- void SetButtonDownSprite(string name)
{
buttonDownSpriteId = sprite.GetSpriteIdByName(name);
}
--- End code ---

That should update the internal values and should work properly.


Hope that helps.

Navigation

[0] Message Index

[#] Next page

Go to full version