ActionScript 3.0 :: Flash HitTestPoint Not Detecting Collision
Jun 3, 2010
I am trying to use hitTestPoint to test whether the x/y coordinates of many circles are colliding with the pixels of another movie clip, but it is not working. It works fine when the ShapeFlag is set to FALSE, (circle detects the boundary box), but not when ShapeFlag is set to TRUE.I have spent hours trying to figure out what could be the issue, but to no avail.Class Ball - called by MAIN program multiple times to create instances of Ball and bounce them around the screen. If Ball collides with DQ (another MovieClip on stage), then it should stop moving:[code]
View 3 Replies
Similar Posts:
Oct 16, 2009
In my file (AS2), I have a small square at the middle of the page. Diagonally to the right, I have a vertical wall which is a rectangle. Pasted inside my small square, I have the code:
onClipEvent(enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (this.hitTest(Wall._x, Wall._y, false)) _x =
[code]......
View 1 Replies
Feb 24, 2005
Is there a way to detect what movie clip is in a certain location? For instance, if I enter some random coords, like x=15, y=0, is there a way it will return the name of the movieclip thats occupies that location?
View 1 Replies
Oct 4, 2002
how i can get these lasers to work in the correct manner. For some reason, 2-3 seconds in the game, the game goes to the next frame. I can't get the second player's fire to stick with him as he travels across the screen. Here's the fla.
View 14 Replies
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
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
Mar 7, 2011
I've been developing a game that uses hitTestPoint to determine a collision between an ball and a shape. This method has been working fine if I just test the swf in flash but as soon as it's embed in a browser the hitTestPoint stops function.
View 2 Replies
May 15, 2011
Is there a way of verifying if the mouse is over an object like the MouseEvent class verifies, not by verifying with hitTestPoint? hitTestPoint calculates bases on the mouse coordinates, but I also need to know that even if the coordinates are over the object, there is not a second object over the target object.
View 1 Replies
Aug 17, 2010
I am currently working on a project that involves dropping objects (scrabble letters) onto different cells in a table. My project also involved multiple levels. My layout is rather basic. I have a a bunch of tiles (25 letters) above a 2-columns table (left side for definition, right for answers). The table is static from frame 1 til the end (no keyframe, blankframe, etc.). The problem is as follows: The exercise starts fine with the first Level, then I click a button to access the next level, and so on... Going FORWARD on the timeline seems to be working OK, I am able to complete each levels in succession. However, if I decide to go backwards (replay a previous level) I can no longer place tiles on my table (hitTestPoint not returning what it should). I checked and my "target" is indeed there but somehow the hit test does not register.
[Code]...
View 1 Replies
Dec 15, 2011
I'm trying to create a boundary for a player object, controlled with arrow keys, in my game using the main stage's height and width. For example, one test point is at the top edge of the player object's bounding box so that when the player object's head touches the stage's top edge, the player can't move anymore to the north. The player object is manually instantiated to the center of the stage by using the Flash stage editor so it will start at the center before the program starts.The problem is that right at the start of the program, I can no longer move the player object up or down with the arrow keys but I can still move it left or right. The intention is to allow the player to move north until the player object's head touches the top edge of the main stage.[code]
View 1 Replies
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
Jan 30, 2011
I'm trying to set up a collision so that when a bullet hits a wall it is destroyed. Here is the snippet of code I am using: PHP Code:
[Code]...
This method works great for when detecting a collision between other moving instances and the walls, but for some reason with the bullets I get this error message when they almost touch the wall and Flash freezes and I usually have to restart it: PHP Code:
[Code]...
View 2 Replies
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Jan 31, 2010
I am trying to use boxes for hit collision. I want to be precise with the collision so I was thinking about making multiple small boxes and checking for collision that way. This maybe a stupid idea or a smart one. If I do this way will that affect the performance of the game even though the boxes are invisible and wont be drawn on the stage.
map out the object starting from its center outward. Like right, left, top and bottom. I am creating a flying shooter so the plane has a long wing span. I could also map out the wing span and tail and so on.
View 2 Replies
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
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