2D Toolkit Forum

2D Toolkit => Support => Topic started by: ferr on January 06, 2013, 04:56:07 am

Title: Handling OnMouseUp event with a Sprite?
Post by: ferr on January 06, 2013, 04:56:07 am
I just started using the 2D Toolkit, really liking it so far, but I'm stuck on something.

Should I be able to use OnMouseUp with a Sprite object? It doesn't seem to handle it at all. I setup a simple scene with an ortho camera and 1 sprite, added a script with an OnMouseUp function and the function doesn't fire when clicking the sprite. Am I missing something?

I'm making a card game and I thought it would be great to use TDK with the cards, using Sprite objects for the cards, but I need to be able to click the cards.
Title: Re: Handling OnMouseUp event with a Sprite?
Post by: unikronsoftware on January 06, 2013, 03:36:22 pm
It should work as long as you have a collider set up, and the collider is behind the camera - i.e. it should be inside the camera frustum.
Title: Re: Handling OnMouseUp event with a Sprite?
Post by: ferr on January 06, 2013, 04:27:04 pm
It should work as long as you have a collider set up, and the collider is behind the camera - i.e. it should be inside the camera frustum.

That worked, thanks a lot!

It should also be mentioned that the "Collider Type" for the sprite in the sprite collection should not be set to "Force None", otherwise you won't be able to add a collider. User Defined worked for me.