I'm currently working with crafty.js. I need to know how to detect when one sprite is moving away from another sprite.
closed as not a real question by Anko, Byte56♦, bummzack, Josh Petrie♦, msell Apr 25 '13 at 8:57
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
So I'm assuming you have an X/Y coordinate for each sprite, and some kind of loop that executes in your game. Given that, just calculate the distance between the two sprites each cycle in the loop. Compare the current distance from the distance in the previous loop, and if it is more, they are moving apart.
Something like this...
I believe you could just not do the square root calculation, as you really don't care about the exact distance, just whether one is farther away than the other. So just...