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.
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. -
oops double post
-
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
andy
property of a Viewtouchmove
event and see if it's over your other element. -
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.
-
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.
-
alright I will try again.
Button1 being moved left to right via animation
Button2 being moved up and down via animationwhen these 2 eventually touch I want a event to happen.
-
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.
-
no for example if a image is moving, and touches another