Hello Guest

Author Topic: Handling OnMouseUp event with a Sprite?  (Read 4366 times)

ferr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Handling OnMouseUp event with a Sprite?
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Handling OnMouseUp event with a Sprite?
« Reply #1 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.

ferr

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Handling OnMouseUp event with a Sprite?
« Reply #2 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.
« Last Edit: January 06, 2013, 04:35:39 pm by ferr »