Skip to content

How to call a function when 2 objects stop overlapping #2517

Answered by RichardBray
NikRetaNCAM asked this question in Q&A
Discussion options

You must be logged in to vote

So there are two ways to achieve what you want to do. I say two there are probably way more but only two that I know of.

  1. With Flixel's basic collision and overlapping
  2. With echo's more advanced collision and overlapping

1. WIth Flixel

You can use FlxG.overlap to check if two objects have overlapped.

FlxG.overlap(mov, stat, (_, _) -> functionA());

To detect if the two objects have exited overlapping with just plain old HaxeFlixel is a little more difficult.

What you could do is have a boolean variable that
triggers when they overlap and in the update function check if they are not overlapping when that boolean variable is true.

// just below class name
var objectsTouched = false;

// insi…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@NikRetaNCAM
Comment options

@Geokureli
Comment options

Answer selected by NikRetaNCAM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants