HitTestPoint All The Way Or Check If Distance < Something First Then HitTestPoint?

Jan 1, 2011

Which one is more efficient? Or is there even a noticeable difference? I did tests of a circle moving closer to a square and stopping when hitTestPoint returns true. The square was at 0 and the circle was at 500. My first test I did using hitTestPoint the entire time, my second test I did by checking the distance (Pythagorean Theorem way) and if it's below 50 then check with hitTestPoint.

I compared the FPS of each test but they were the same at 30 FPS with 200 circles and at 11-12 FPS with 500 circles. I thought the first test would be slower because I was testing every pixel the entire time while the second test I was only calculating the distance for the most part before testing every pixel.

View 2 Replies


Similar Posts:


HitTestPoint Is Not Working?

Jun 15, 2010

I'm trying to make a simple platform shooter game, although I just cant seem to get jumping right. hitTestObject works fine, but hitTestPoint doesn't seem to work at all.[code]on that last bit, if I use hitTestObject instead, it works fine, but when i use hitTestPoint, I just fall through the ground as if nothing is there.and I want to use hitTestPoint so I can make floating blocks

View 2 Replies

ActionScript 3.0 :: Why Is HitTestPoint Not Working

Jun 9, 2011

I'm probably missing something about which parameters I'm supposed to be passing.Here is the code:In the first class (the hitting object belongs to this class):[code]It always traces "Didn't work" when I drag the instance of the first class over the instance of the second class. What am I not understanding about the hitTestPoint function?

View 16 Replies

ActionScript 3.0 :: CacheAsBitmap And HitTestPoint?

Sep 19, 2011

Why does hitTestPoint isn't working on DisplayObjects that has cacheAsBitmap set to true?It does work, but it takes the Whole rectangle of Display object, not respecting wheather or not pixel is transparent or not (transparent pixels return true after hiTestPoint)

View 3 Replies

ActionScript 3.0 :: Cant Get HittestPoint To Work?

Jan 20, 2011

im trying to create a menu that drops down when you roll over it. however I cant get hittestPoint to work.I have a movieClip on my stage with a class attached. Inside this movieClip is another movieClip with an instance name of "hitBox"

ActionScript Code:
package {
import flash.display.*;
import flash.events.*;[code].....

Is it possibly to do with the mouseX and mouseY being local?

View 1 Replies

ActionScript 3.0 :: HitTestPoint Not Working Right

Nov 20, 2011

Anyone know why "hitTestPoint(character.x, character,y, true)" would be hit testing off the origin point in the center of the character, and not the whole shape??This is my code from my document class. There's a custom splat class in there, but don't worry about that. This code is inside 2(1 nested) for loops.[code]

View 1 Replies

ActionScript 3.0 :: HitTestPoint & Mouse_move?

May 19, 2009

I have been using hitTestPoint so far with mouse_move listener, which means if the mouse was stationary over target area when that listener was added the desired action wont happen until mouse moves.

Basically I have this window in the middle of the stage where loader loads pictures and when picture loads if the mouse moves over that window some other stuff appears.The listener is added after each picture is added and if the mouse was stationary above the loader when that happened it doesnt trigger hitTestPoint (until mouse moves).

I have seen somewhere this same effect, but it worked even if the mouse was stationary above the image when image appeared.

[Code]...

View 2 Replies

ActionScript 3.0 :: HitTestPoint Not Working?

Mar 3, 2011

I have the beginning of a game that looks a bit like Asteroids. The first version of the game worked, but was very code-heavy (every object was individually coded) so I decided to move the bulk of the code to document classes.

I wanted to have certain objects interact with eachother (bullets with asteroids, asteroids with ship, etc.) but they can't find eachother. Also, as you may notice in like a second from now, the whole code is handled by a single document. I guess I should do something about that as well?

Code:
package
{
import flash.display.MovieClip;
import flash.text.TextField;

[code]....

View 5 Replies

ActionScript 3.0 :: Multiple HitTestPoint With Arrays?

Mar 26, 2009

How would I change this to do a few test points,if (mydude.hitTestObject(myratarray[i])){

is it along these lines? if (mydude.hitTestPoint(myratarray[i].34,myratarray[i].12,true)){

View 2 Replies

ActionScript 3.0 :: Image Transparency And HitTestPoint?

Jun 26, 2011

I'm not sure this is even possible, but does anyone know how to get the hitTestPoint function to ignore transparency for a MC containing a png image?

View 1 Replies

Flash :: Use HitTestPoint When A Movie Is Scaled?

Oct 20, 2010

Google says that[code]...

is the way to test for the mouse being over a DisplayObject. This works if my movie is displayed at 100% scale. But if maximise my browser window so the Flash movie changes scale, it all goes to pieces.

View 1 Replies

ActionScript 3.0 :: HitTestPoint With Nested Object

Jun 28, 2010

Recently I was trying to use hitTestPoint with a nested movieclip against another non-nested one. Then if the nested movieclip was found to collide with the the registration point of the other movieclip (shapeFlag was set to true of course), the nested movieclip would move down by 1 pixel until it wasn't colliding.[code]What happens is that the while statement doesn't kick in until the registration point of obj3 is over obj2, but it doesn't break until obj3 is not over the bounding box of obj. Alternatively, if I change obj1.obj2.y to obj3.y it does stop at the correct spot.Actually I guess the problem isn't obj2 being nested in obj1, the problem still occurs when it's taken out of obj1.

View 8 Replies

ActionScript 3.0 :: HitTestPoint Stops A MovieClip

Nov 1, 2010

I have my two MovieClips and I both of them collide and the hitTestPoint works, but I want to make that one MovieClip will not be able to go on if that second MovieClip is in front of it but its can turn so that it to another side so that it can move.

View 0 Replies

ActionScript 3.0 :: HitTestObject / HitTestPoint Not Working Sometimes

Oct 8, 2011

Why does this happen ?

Code:

Main:
ActionScript Code:
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;

[Code].....

View 0 Replies

ActionScript 3.0 :: Change Code To HitTestPoint?

Mar 4, 2012

I've followed a tutorial and everthing works fine but I'd like to use hit-tests instead of the intersect-code. change the code so it works just the same with hit-tests.I dont get the same result.

View 4 Replies

ActionScript 3.0 :: HitTestPoint( X, Y, True); Implementation?

Jun 2, 2009

Testing this function and running it 11k times on a shape where I use:
 
shape.opaqueBackground = true;            shape.cacheAsBitmap = true;
 
Is extremely slow.. It seems to take 4 to 5 seconds to check a 101 x 101 tectangular area.I'm wondering how it is implemented...I know the code for the SDK is available?I can 'getPixel' from a bitmap to get the very exact color of that pixel in 1/1000 that time.If I happen to have the bitmap data.But with a shape that is already 'treated as a bitmap' (see above) using hitTestPoint  can stop your system. It should not be vastly inferior to work with Shapes than it is with bmp data..

View 3 Replies

ActionScript 3.0 :: HitTestPoint Inside A MC Not Working?

Aug 16, 2009

PHP Code:

//Move Enemies Events
function moveEnemies():void {
//Runs through every enemy stored in the array.
for(var c=0; c<enemyArray.length; c++) {

[code]....

View 11 Replies

ActionScript 3.0 :: While Loop & HitTestPoint Malfunction

Feb 15, 2010

[Code]....

This code serves the purpose of raising the character upon going up a hill. However, since the game will be on a large space (larger than the document size 1000x750) I am moving the ground (mc_Blockers) instead. This code is supposed to push the mc_Blockers down then it intercepts with the characters y. But instead, it just throws the character really high. When I examined it closely, it seemed to me that it threw the character up till the bounding box of the mc_Blockers (the whole stage is drawn, I'm not using blocks for floor, etc.).

View 1 Replies

ActionScript 3.0 :: HitTestPoint Trouble When Moving Root?

Jan 18, 2010

basically, I'm having trouble with the hitTestPoint method. As soon as I move the root of the swf, it no longer works as it should.To see what I mean, run this code:

Code:
package todd.test
{

[code].....

View 6 Replies

ActionScript 3.0 :: HitTestPoint - Hittest Doesn't Work?

Dec 30, 2008

I have this code so that when a spaceship goes through a blackhole it plays the spaceships moveiclip. This works fine on the first part of the code when the user just clicks the start button.However, i have put in a difficulty setting and when you change the difficulty setting the hittest doesn't work anymoreand there are no error messages. I have tried putting the blackHoles array in the difficulty function but nothing changes and i didn't really think this would make a difference as the easy function is already using the blackHoles array outside the difficulty function.

View 7 Replies

ActionScript 3.0 :: Get HitTestPoint Data As An Array Or List?

Oct 5, 2010

So, pretty much I have made a little flash app for a project at uni, and I have a tree which these little bat creates land onI have drawn the tree as a MC, and then use a hitTestPoint function to check wether the centre point of each bat character is touching the tree. If so land... blah blah pretty simple.Except I need to create a function that actually randomly spawns these characters on the tree. So to do this i would ideally have a get function that collects every x and y point on the and stores this data into a list

View 8 Replies

ActionScript 3.0 :: HitTestPoint And Defining A Range Of Values?

Sep 15, 2011

Is it possible to definine a range of values for the x or y parameter of hitTestPoint?

For example... hitTestPoint(100, rangeOfValues, false);

I've tried a few different things but nothing has worked so far.

View 1 Replies

ActionScript 3.0 :: HitTestPoint Not Recognizing Full Shape?

Nov 20, 2011

why "hitTestPoint(character.x, character,y, true)" would be hit testing off the origin point in the center of the character, and not the whole shape??

This is my code from my document class.  There's a custom splat class in there, but don't worry about that. This code is inside 2(1 nested) for loops.
 
function hitTestBalls(e:Event) {
for (var i = ballArray.length - 1; i >= 0; i--) {
for (var m = MonsterArray.length - 1; m >= 0; m--) {

[Code]....

View 3 Replies

Flex :: HitTestPoint Not Giving Correct Results

Sep 27, 2010

I have a movie clip on which I have added a MouseEvent.MOUSE_OUT listener.[code]...

Now the logic is to remove the movie clip on MOUSE_OUT and add it back to stage on MouseOver of another button. The intended functionality is like a slider showing some info

The MouseEvent.MOUSE_OUT firing in this case is not functioning always as expected. When I move the mouse out of the moveclip fast it fires. If I moveout very slowly it does not fire and consequently the movieclip remains on the stage. [code]...

View 4 Replies

ActionScript :: Multiple Object Instantiation HitTestPoint

May 20, 2011

I am instantiating the 'Target' object five times on the stage. This is happening, but only one object is able to have hitTestPoint performed on it. Can anyone help as to why this is happening?[code]

View 1 Replies

Actionscript 3 :: HitTestPoint Always Returns False For One Function

Sep 18, 2011

I have a movieclip I drawn, called Map. It has a child with the name Wall. I'm trying to make a function that returns a 2d tile array of if there is something in that tile or not, for pathfinding. The problem is, levelGrid is entirely false. I'm not sure what I am doing wrong. I have filled the whole movieclip (Wall) with bright red, and yes it still returns false. The x and y of both Map and Wall is 0, so I don't think there should be issues with hitTestPoint accepting global x / y.

[Code]...

View 1 Replies

Actionscript 3 :: HitTestPoint() Not Testing For Collisions Correctly?

Feb 22, 2012

I'm writing a game and it has enemies and bullets. When a bullet hits an enemy, I want to destroy the enemy and the bullet. I'm using the hitTestPoint() method to test if a bullet has hit an enemy. Here's the code in my game loop:

[Code]...

The problem is, hitTestPoint only returns true if both the x and y values of bullet and enemy are the same, rather than if the two movie clips overlap. This leads to bullets going right through enemies but it not registering as a hit. Perhaps I'm missing a bounding box?

Is there a way I can make hitTestPoint return true if the bullet hits the enemy at all rather than only if the bullet and enemy co-ordinates are the same?

View 2 Replies

ActionScript 3.0 :: XML Gallery - HitTestPoint Stop Scrolling?

Jan 18, 2010

I am making an xml driven gallery, with scrolling thumbnails that sit along side of the main image, in a column. These thumbnails scroll depending on the mouses Y position over the column that they sit in. If the mouses position is below the halfway point of the column, the thumbs scroll down, and then if you go above the halfway point the begin to scroll upwards they scroll up until you reach the top image, and it stops...

However, my problem is that when the thumbs have scrolled to the bottom image in the column, unlike when it reaches the top, the scrolling function doesnt stop, it just keeps going until the thumbs have completely scrolled out of shot. What I would like to do is make sure that, the scrolling function stops when it reaches the bottom image; the same as how it stops when it reaches the top...

So if the bottom image rises above the bottom of the column that holds the thumbnails, the thumbs stop scrolling, and will only be able to scroll upwards. Here is the code for the scrolling function that I have:
ActionScript Code:
thumbContainer.addEventListener(Event.ENTER_FRAME, scrollThumbs);
private function scrollThumbs(e:Event):void {
if (thumbContainerMask.hitTestPoint(stage.mouseX, stage.mouseY, false)) {
[Code] .....

View 0 Replies

ActionScript 3.0 :: HitTestPoint Partially Hidden Movie?

Nov 8, 2010

I have a couple of movies, one of them hiding partially the other one. I would like to detect when someone clicks on a movie. I know that this can be done easily by using the hitTestPoint function. The problem is when the user clicks on the intersections of these movies. In that case the hitTestPoint function says that the user is clicking both movies. But actually the user is clicking only one movie, because the other movie is partially hidden. How can I program this behavior in a natural way?

View 3 Replies

ActionScript 3.0 :: HitTestPoint Written In Wrong Order?

Mar 25, 2011

i have a function that works fine but is obviously the wrong way round. how do i write it so that the event happens if it is true. at the moment it happens when it isnt true in the 'else' statement.

[Code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved