ActionScript 2.0 :: Bitmap Hit Testing - Pixel Perfect Collisions

Mar 31, 2007

I have been desperately searching for a way to do pixel perfect collisions, and for someone to explain it to me in detail. explain the code in the .fla file, posted by the Canadian in the frequently asked questions thread on bitmapData hit testing:

[Code]...

after looking through the help files, i must admit they are terribly vague. All you are doing is checking if _alpha is above a certain amount. With movieClips you would use 0->100 but with this hittest you have to use 0->255 (0x00->0xFF)so an _alpha of 50 would correspond to approx 128 (0x80). Nearly all the time you could just use 1 as a hittest parameter so you are checking for any hit at all but maybe you have a shadow in a mc layer and you do not want to check a hit. This is when you might be able to use your threshold parameter. In other words, the hit test will only react to parts of the bitmap which have a greater or equal alpha than the alpha threshold, mostly useful for a shadow.

View 1 Replies


Similar Posts:


Professional :: Pixel Perfect Hit Test?

Nov 13, 2011

What is the SIMPLEST way to make a pixel perfect hit test class?

View 41 Replies

Flash :: Get Perfect Pixel Line Rendering In As3

Jan 7, 2010

I'm making an arcade game in as3 and I want to draw pixely(unsmoothed by flash) lines. I'm drawing the pixels 'by hand'(not with flash's lineTo or anything) onto a bitmapdata object. The lines don't appear quite right though, when zoomed out the line is rendered 2 pixels thick at some parts. However by zooming it its apparent that the algorithm is fine and its not doubling the pixels. Changing the quality doesn't seem to change anything.

[Code]...

View 2 Replies

ActionScript 3.0 :: Blitting + Pixel Perfect Collision?

Oct 23, 2011

I'm using a blitting engine that uses bitmapData. No display objects.Is there a fast pixel perfect collision detection available for such a game system?I already tried CDK but that didn't work because it assumes you have display objects which my objects don't use. Sometimes my objects are pretty big and hitTest sucks in this case. I already tried circle-to-circle collisions but that didn't do the trick either.

View 1 Replies

ActionScript 3.0 :: Pixel Perfect Collision Detection?

Jul 11, 2009

need build pixel based collision dectection class , i have found some classes already built by different people and they are really usefull, but as i want to build one of my own, i need to know basic theory behind tha

View 3 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 2.0 :: Testing For Collisions Between Rotated Objects

Oct 14, 2006

I'm writing a general physics engine and I've come across the problem I've always had with flash. So far all my hittests in my physics engine have been calculated by using x/y coordinates and the 2 objects dimensions. This has worked fine for the objects so far because they have been very square-ish and do not rotated. How ever now I am trying to detect if 2 rotated objects are hitting. How can I do this ? I would really like to avoid using any .hitTest() functions.

View 5 Replies

ActionScript 3.0 :: Movieclip Hit Area, Set To Dimension, Instead Of Pixel Perfect?

Dec 4, 2010

i have a simple movieclip, based off text, with a few frames, and instead of creating an invisible area to do the hit test, is there any way to set the hit area to equal the movieclip's dimensions?, google seems to not be able to provide results, i don't need pixel perfect hit detection, but rectangle detection

View 2 Replies

Actionscript 3 :: Find A Pixel-perfect Collision Detection Function

Mar 18, 2010

I was searching for a simple collision detection function for as3, I found Collision Detection Kit, but it is too complicated, I just want a damn function that I give 2 objects as paramenters and that's it.I would like to know where can I find a pixel-perfect collision detection function (The faster, the better)

View 2 Replies

ActionScript 3.0 :: Pixel-perfect Collision Detection With 5000+ Particles?

Dec 5, 2009

I just thought I'd drop a note here to those who are interested. I recently posted about it on my website and you can download the source for it there too. Here's some excerpts:

Ive run it at 60+ FPS with 7,000 particles, but that actually isnt the limitation (unless your particles are crunching heavy math for eg movement). Rather its the size and number of sprites that were colliding with the particles.

To squeeze all the juice out of Flash I employed a couple tricks. The first was the particles themselvestheyre blitted to a single bitmap which is used as the source image for grabbing collision data from. The particles are also drawn with the raster engine in Flash (multiple setPixel32() ops to give the illusion of a line a choppy one anyway) instead of the vector renderer (lineTo()).

The second trick was to only grab a Vector of pixels from the regions we cared about (within sprite boundaries) every so often, then to loop through the Vector and test it against our desired conditions. Also, since the particle bitmap is more sparse than our sprites as far as opaque pixels go, we test the particle bitmap first, resulting in a lot fewer passes on the first round of conditional statements.

That's the gist of it, but I explain it a bit more in detail in the post. Hope someone finds this useful and please let me know if you come up with something cool using it

View 5 Replies

Flex :: Comparing Bitmap Data In AS3 Pixel For Pixel

Mar 30, 2010

I am looking for a fairly simple image comparison method in AS3. I have taken an image from a web cam (with no subject) passed it in to bitmap data, then a second image is taken (this time with a subject) to compare this data, from these two images I would like to create a mask from the pixels that match on both bitmaps. I have been scratching my head for a while, and I am not really making any progress. Could any one point me in the right direction for pixel comparison method, something like getPixel32()

View 2 Replies

ActionScript 3.0 :: Get Pixel-by-pixel Bitmap Data?

Nov 23, 2009

I have a 100x100px image. I want to get 1 pixel vertical line from x- 1 to 100. How can I do that?

View 7 Replies

ActionScript 3.0 :: Separate Touching Collisions From Overlapping Collisions?

Nov 22, 2010

I'm working on a game (my first) where objects touching is A-Ok, but I want to detect overlapping collisions ahead of time, prevent them, and react. This seems like a pretty basic and common thing, such as a character walking along a platform (even though by touching it it's 'colliding'), but of all the many many collision detection tutorials I've looked at, none of them have covered this case--they all assume that objects touching should be indistinguishable from overlapping. I've been using a workaround of a slightly smaller hitbox to use for collisions, but it has issues of it's own that make it not so good. So basically I'm looking to redo my CD from scratch.

So, like I said, I'd like to know how to differentiate between 'touching' collisions and overlapping collisions, but even a way to keep touching collisions from triggering entirely would work.

View 9 Replies

Actionscript 3 :: Itarating Each Pixel Of A Bitmap Image

Mar 11, 2011

Is it possible to iterate each pixel of a bitmap image? Eventually what I'm trying to achieve is that I need to get the coordinate values of each pixel of a bitmap image and change the color of those pixels according to their coordinate values. As I see it, I need to use the getPixels() method but I still did not understand exactly what I should do.

View 3 Replies

ActionScript 2.0 :: Check When Pixel Is Transparent / Not In A Bitmap?

May 31, 2010

Can I check if a pixel is transparent or not in a bitmap?

I want to count the nr of transparent pixels and nontransparent pixels.

View 0 Replies

ActionScript 3.0 :: Convert Bitmap Into Sprite Pixel At A Time?

Nov 21, 2010

I'm making a game where the player moves around a map, where the player can walk and where they can't is decided by the color of the pixel they are trying to move onto, which I get using the Bitmap.getPixel method.

What I'd like to do though is when the map image is loaded process it into a sprite or something which I can then use the DisplayObject.hitTest methods on. So I have an array of colors whcih the user can walk on, is there way I could go through each pixel and build something that would let me do that?

View 4 Replies

ActionScript 3.0 :: Check Pixel Color Value Of Bitmap Through MouseEvent

Oct 5, 2011

I have a bitmap with many colors on it. When the user clicks each color needs to trigger a different method. However, I have no idea how to check the color value of the selected bitmap. I can create a new sprite and check the value of that fine through bitmapdata.getpixel() but when I need to actually check the actual bitmap I cannot get it to work.

View 2 Replies

ActionScript 3.0 :: Pixel Alignment Of Children Bitmap With Scale/rotate?

Dec 14, 2008

I'm implementing a frame class that builds a graphical frame around children using 9 bitmaps (4 corners and 5 middle pieces).The frame extends sprite, and the 9 frame bitmaps are attached as children. They are repositioned as necessary to encompass any other children on the sprite.

This works fine, normally, but as soon as I rotate or scale the frame, the children split apart, showing what appears to be a one pixel or partial pixel gap between the pieces.

I've tried setting pixelSnapping = PixelSnapping.NEVER on the 9 bitmaps. I've tried turning smoothing=true. The children bitmaps are always positioned at integer x, y's, never fractional. I've tried setting the scale of the children bitmap to 1.01 and PixelSnapping to AUTO. None of it works.

View 4 Replies

Flash :: Search BitmapData Object For Matching Pixel Values From Another Bitmap?

Jun 16, 2010

Using Actionscript 3 is there a way to search one bitmap for the coordinates matching pixels of another bitmap?

[URL]

Somehow you would have to loop through the bigger bitmap to find and the the pixel range that matches and return those coordinates. For example the Bitmap with the "E" is 250 pixels over and 14 pixels down in the bigger bitmap.

View 2 Replies

Actionscript 3 :: Get An Accurate Reading Of The Pixel Data From A Bitmap With A Matrix Transformation?

Mar 24, 2011

i've filled a circle shape with the bitmap data of a bitmap asset.i need to rotate the circle from the center, so i added the bitmap to the center of the circle and used a matrix transformation to shift the bitmapdata upward and leftward so it appears centered.
now i'm trying to read the bitmap data with getPixel() but the return value is off since it is returning the untransformed position of the bitmap data instead of the visible transformed bitmapdata.

Bitmap(Sprite(evt.currentTarget).getChildAt(0)).bitmapData.getPixel(evt.localX, evt.localY)

how can i get an accurate reading of the pixel data from a bitmap with a matrix transformation? updated with code. assume the redCircleData in my example is more colorful and something worth retrieving pixel data.

var redCircleData:Sprite = new Sprite();
redCircleData.graphics.beginFill(0xFF0000, 1.0);
redCircleData.graphics.drawCircle(0, 0, 100);[code]............

View 2 Replies

Actionscript 3 :: Flash: Bitmap Inaccuracy - Image Appears To Shift One Pixel?

Oct 12, 2011

I load a bitmap to the stage, it's a GIF and set to lossless compression. I have ensured its coordinates are integers and have not allowed smoothing (smoothing somewhat fixes the issue but reduces quality of the image).The problem is the image appears to shift one pixel to the left and add that pixel on to the right side meaning one side has no border and the other a double border.The original bitmap does not have this issue, and there is no transparency .etc in the image.

View 1 Replies

ActionScript 2.0 :: Testing A Function Is Complete Or Testing 2 Tweens Have Finished

Feb 2, 2011

I basically need to scale an object up when the user rollsover the button which I have created dynamically already and I need to make sure the object is fully scaled up before I can allow the user to scale it back down again.Ive tried putting 2 tweens (x and yscale) into a function but not sure how to check if the tweens have finished. Im assuming if I check the function is complete it wont take into consideration the tweens may still be running.

View 0 Replies

ActionScript 2.0 :: How To Do A Perfect Load Of A GIF

Feb 28, 2006

i have a GIF and i want it to be loaded dymanicly from XML with [code]the GIF isn't playing. my GIF has 4 stages (frames) but when loaded, it stays only on the first one. i need the GIF loaded and begin looping all 4 frames... what's happeing ?i want the loader_MC to be resized everytime i resize my Stage. i did this:[code]The GIF appears distorted, turned upside down and the _x axis very wrong and out of page... what's happening, again?

View 3 Replies

Cant Get Collisions To Work

Jan 23, 2009

I am making a game and I cant get my collisions to work. I will give a link to the files because I use external .as files.

View 1 Replies

ActionScript 2.0 :: Perfect Keyboard Movement?

Jul 11, 2009

on the stage, ther's a box. you can move the box with the left and up key.i have 3 problems:

1. the movement isnt smooth, can i make the movement smooth without modyfing the speed?

2. i want that when you press the left and up key simulteanously the box will move diagonaly.

3.when you press and hold a key, the box just moves a little and after 1 second (or something like this) the box starts to move continously. can I make the box to move continously immediatly after you are pressing a key.

View 2 Replies

ActionScript 2.0 :: Perfect RollOver And RollOut?

Sep 28, 2011

I've been searching around and can't quite seem to find the answer. I gather it's a problem with actionscript, but, i digress.

What's going on is if I move my mouse too fast it won't activate either the RollOver or RollOut, and it'll just stay. Is there a certain way I need to set everything so it will NO MATTER WHAT animate when rolledover, and then ALWAYS RollOut?

View 2 Replies

ActionScript 2.0 :: Get Perfect Scroll Percentage?

Oct 22, 2009

i want get scroll percentage form 0 to 250 point having a Line large 95px and dragger large 10px. I make this script but it dont perfect to get value. It's fast to update value.[URL]

dragger.onPress = function() {
dragger.startDrag(false, 0, -14, line._width-dragger._width, -14);
this.onEnterFrame = updateValue;

[code]......

View 1 Replies

ActionScript 2.0 :: Perfect Fade/multibuttons?

Aug 22, 2004

I picked up code for the "perfect fade" a while ago, which I have used for buttons in te past.

The code is as follows. On the root timeline:

[Code]...

Now this all works great, but its not too modular, meaning I have to write a fair amount of code for each button.I'm trying to make it leaner, by having a global function, but I can't get it to work properly... i think due to the enterframe. I've been unable to make it loop, and therefore it only steps forward oneframe, and back one frame.

View 1 Replies

Swf Works Perfect Offline But Not When It Is Uploaded On The Internet?

Oct 12, 2009

this is my first flash test and I have been stuck for weeks to solve this issue. I am currently with Mediatemple, standard gs plan, and I have three files that I wish to upload:
 
index.html (html file)
ProgBar.swf (Preloader)
Main.swf (External Swf that is being loaded)
 
If you open the html file locally on a computer, it works fine, however the problem arises when these files are uploaded to the internet,. It doesn't seem to work at all... Please help me figure out why. Thank you for your consideration.

View 2 Replies

ActionScript 3.0 :: A Perfect Half Circle Using Only The Drawing API?

Dec 17, 2008

any techniques they use to draw a perfect half circle?

I've seen the curveTo() method, and I cannot seem to make it come out with anywhere nearly good enough results. It always looks like half of a skewed ellipse.

I don't *want* to use a mask -- since there will be other drawings on this same Sprite that I do not want masked.

To be even more picky -- I don't *want* to create the half circle in another Sprite and add that to my original drawing.

View 9 Replies







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