Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Triggering a event..

Hey is it possible to trigger a event when one object touches another, example

I have a image 1 in one location i want image 2 to pass over image 1 and i want to fire a event.

thanks.

— asked March 16th 2010 by scott castov
0 Comments

8 Answers

  • Do you mean "pass over" as in animation? I'm not sure I understand the question. You can use fireEvent method on all objects to fire events on behalf of objects if you'd like.

    — answered March 16th 2010 by Jeff Haynie
    permalink
    0 Comments
  • oops double post

    — answered March 16th 2010 by scott castov
    permalink
    0 Comments
  • I'm sorry but you're not being clear in what your asking so I can't seem to help you. Please re-state your question in a way that can help us understand.

    How is your image moving? You said "no for example if a image is moving" – so, it's not moving via animation (controlled by your app).

    Is it moved by a user's touch?

    If moved by a touch, you can always look at the x and y property of a View touchmove event and see if it's over your other element.

    — answered March 16th 2010 by Jeff Haynie
    permalink
    0 Comments
  • Scott, I think what Jeff's getting at is "what is causing it to move?" Depending on why/how it's moving, the answer may be different.

    — answered March 16th 2010 by Greg Bulmash
    permalink
    0 Comments
  • Scott, I think what Jeff's getting at is "what is causing it to move?" Depending on why/how it's moving, the answer may be different.

    — answered March 16th 2010 by Greg Bulmash
    permalink
    0 Comments
  • alright I will try again.

    Button1 being moved left to right via animation
    Button2 being moved up and down via animation

    when these 2 eventually touch I want a event to happen.

    — answered March 16th 2010 by scott castov
    permalink
    0 Comments
  • I think what you're wanting is a gaming framework type of built-in sprite collision detection, but this isn't a gaming framework.

    If you know where each button is on the screen and you know the size of each button, you can tell when they've collided. You just check whether one button's bounds have crossed/overlapped another button's bounds. It's a bit more complicated to do this than to use an built-in collision detection function, but that's what the collision detection function would basically be doing for you.

    — answered March 26th 2010 by Greg Bulmash
    permalink
    0 Comments
  • no for example if a image is moving, and touches another

    — answered March 16th 2010 by scott castov
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.