Skip to main content
Participating Frequently
May 7, 2011
Question

Help figuring out how to tell if an object is within a dynamically made circle

  • May 7, 2011
  • 2 replies
  • 435 views

Hello Everyone,

I am currently in the middle of working on a project but sadly I am having a bit of trouble getting a few things figured out.

Essentially what the project consists of is I have random balls appearing on the screen and moving around and I need to make it so that the user is able to draw a circle around the ball (may be more than one) and have that balls dissapear and count the number of balls circled.

This project is being done in flash builder 4.5 and is being made for the android platform as part of a senior project.

At this point this is where I am.. I have been able to randomly create the balls and give them a random movement. I have also been able to figure out how to allow the user to draw on the screen.

What I am trying to figure out is how to make it so that if the user draws a circle around the balls make it so that I know these balls have been circled and make them dissapear and have the number of balls inside the area calculated.

I have thought about making the entire background a grid and make it so that I can track somehow the line made by the user and then track the coordinate of the balls then if it is within that area it means that the ball has been circled but I would like something more efficient than that.

I apologize if it is unclear for what I am looking for but a simple description is I am making a simple game where you are able to circle a moving item on screen, then once it is circled the item disappearsand you gain a point.

Any help would be greatly appreciated.

This topic has been closed for replies.

2 replies

Inspiring
May 8, 2011

When you say "circle" do you mean an actual circle or a more free form closed circuit that a person might draw by hand? If it is an actual circle it should be pretty easy to just use the radius and distance from center to determine if objects are inside or not.

If it is the looser meaning of circle you might want to do a hitTestPoint.

kglad
Community Expert
Community Expert
May 8, 2011

that's non-trivial.  just determining if your user drew a closed curve is non-trivial.  then deciding what's inside and what's outside that curve is non-trivial.

that's not to say it can't be done or even, that it can't be done with flash.  it can.  but you're not going to get a short paragraph answer to this one unless there are significant assumptions you can use to simplify the problem.