Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums Help figuring out how to tell if an object is within a dynamically made circle
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 05-07-2011, 06:55 PM #1 nashmage Registered User   Join Date: May 2011 Posts: 3 Help figuring out how to tell if an object is within a dynamically made circle 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.
 05-08-2011, 01:54 AM #2 tadster tadster     Join Date: Feb 2009 Location: Texas Posts: 2,111 It should not be too hard if you use pixel perfect collision detection. After the user has drawn the circle, fill it in* with a mostly transparent color, and use that fill space to pixel perfectly hit detect amongst the balls, all the balls that are hitting the area, are inside the circle. *easier said than done, since the user draws the circle. But, I think it should be easy to just make sure that whatever the user draws into has no width or height to begin with, so what they draw determines the width and height, then just fill that area transparently and hit test against it. Troy Gilbert made a really nice pixel perfect algorithm that's just one function. Also there is the Collision Detection Kit by Corey Oneal, in fact it has an example where you can draw the terrain that a ball will land/roll on, you may like seeing that, but I think that may be too intense for phones. __________________ www.actiontad.com - ActionScript and JavaScript sitting in a tree...

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

All times are GMT. The time now is 11:29 PM.

///