ActionScript 3.0 :: BitmapData.hitTest - What Angle Or Coordinate Of The BitmapData The Collision Happens?

Sep 1, 2011

how to use the bitmapData collision method. Now I'm trying to figure out if there is a way to see at what angle or coordinate of the bitmapData the collision happens? I need it in order to figure the accurate bounce angle after the collision occurs.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: How To Use BitmapData.hitTest

Jul 11, 2009

Im making a simple game with destructable terrain. Therefore i use a bitmap for the ground and a movieClip for the player. When the ground is a bitmap i cant use regular hitTestPoint because of the bitmaps transparent pixels. So i looking i the livedocs for the bitmapData.hitTest but i rly dont understand all the parameters.So my question is. How can i reproduce this with bitmapData.hitTest?

ActionScript Code:
if(ground.hitTestPoint(player.x, player.y, true)) {
//actions

[code]....

View 3 Replies

ActionScript 3.0 :: Messed Up BitmapData Collision Detection

Sep 6, 2011

So i've been toying around with the built in bitmap collision detection, seeing as it was pixel-perfect collision testing. I've tried so many times to get it to work, but it hasn't prevailed yet. All the tutorials i've found look like timeline code, but i'm using OOP, however, this should not effect it in any way. I eventually broke down an downloaded a pre written class, but even then, i could not get it to work. Basically, when the two objects are supposed to be colliding, the ground has a red glow, but after making it draw points while colliding i saw that the actual collision shape is some messed up thing.

[Code]...

View 7 Replies

ActionScript 2.0 :: How Does Bitmapdata Hittest Work

Sep 23, 2009

import flash.display.BitmapData;
import flash.geom.Point;
//
var BitmapA:BitmapData = new BitmapData(550, 400, true, 0x00);

[code]....

This is using the bitmapdata.hittest way to check whether the one bitmap is overlapping the other. Throug pixel-to-pixel detection.But I'm having trouble understanding this line:

Code:

if (BitmapA.hitTest(destPoint, 255, BitmapB, currPoint, 255))

I know that destPoint is the topleft point from which it is determining all opaque pixels. No value is given to destPoint so basically it is checking from 0,0. Having determined all opaque pixels from that bitmap it should compare them with the opaque pixels of the other bitmap. But why does currPoint use the topleft coordinate of its movieclip? Couldn't it just as well use 0,0 too? I mean when determining the opaque pixels of bitmap two it might as well start checking for those from 0,0 as the topleft position as well?

View 2 Replies

Flash :: Use HitTest Between BitmapData And An Object?

Aug 23, 2011

I have converted a PNG into a bitmap, then converted that into bitmapData.

I have a object called _player, and I wish to add collision detection, however I can seem to get it to work.

my code is:

if(bmd1.hitTest(new Point(_player.x, _player.y))){
trace("hit");
}

bmd1 is my bitmapData,_player is the object is wish to test against.

I am getting the following error:

1136: Incorrect number of arguments, Expected 3

I have looked around but cannott find what argument I am missing

I have tried

if(bmd1.hitTest(new Point(_player.x, _player.y), 50, _player)){
trace("hit");
}

I should mention that the reason for me taking this approach is that I have a PNG, with transparent areas, I need to test for collisions in the non-transparent areas, which is why I was using this approach

I have a PNG, i import that and convert to bitmap, then convert to bitmapData

View 3 Replies

ActionScript 3.0 :: Using HitTest With BitmapData And The Mouse: Hover Gfx?

Jul 31, 2011

Having used copyPixels to display an image, I'm trying to copy another in it's place when the mouse is hovering.The only way I can copy the new image over the old is by setting the If statement to == false. I know there's something wrong with testing the bitmapData of the loaded .png because the hitTest would apply to anything copied from that tile sheet... but how to designate just the copied area?

ActionScript Code:
package 
{

[code]......

View 4 Replies

ActionScript 2.0 :: Flash 8 BitmapData - Getting Error : The Class Or Interface 'BitmapData.loadBitmap' Could Not Be Loaded?

Jan 31, 2007

I'm using Flash 8, with this code in the first frame:

import flash.display.BitmapData;
rissa._x=Stage.width/2;
rissa._y=Stage.height/2;[code].....

When I publish the file, I'm getting the following error message in the Output panel:

**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 7: The class or interface 'BitmapData.loadBitmap' could not be loaded.
var plaid:BitmapData.loadBitmap("plaid");

Total ActionScript Errors: 1 Reported Errors: 1

View 8 Replies

ActionScript 3.0 :: Error #2015: Invalid BitmapData At Flash.display::BitmapData()

Oct 14, 2009

I am trying to use the reflect class from "http://pixelfumes.blogspot.com/2007/03/reflection-class-v3-with-source .html" but I keep getting this error:
 
ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData()
at Reflect()
at Site_fla::GalleryPage_29/loadThumbs()
at Site_fla::GalleryPage_29/sortXML()

[Code]...

btw, first I used assigned thumbContainer as the mc argument (outside the loadThumbs() function) and it worked but not exactly what I wanted... because I thought it is supposed to update when the movieclip is animated but it actually didn't... when I use a scroller, only the thumbs that are first loaded to the stage get the reflection..

View 10 Replies

Actionscript 3 :: Quickly Rotate The Pixels That Make Up BitmapData Without Using BitmapData.draw()?

Dec 29, 2011

I've been using BitmapData.copyPixels() to draw graphics onto a canvas (Bitmap).I need to rotate the resulting graphics without the use of draw() because it's vastly slower.How can I rotate the target graphic? I'm assuming that there might be a formula or library that I can use which will first reorganize the pixels that make up a graphic based on an origin (point) and radians.I'm pretty certain that I'm not capable of creating such logic, so if there are any known libraries that do this, that would be awesome.I'd like to achieve something similar to XNA's SpriteBatch.Draw() method, which accepts rotation as its 5th argument.

View 3 Replies

ActionScript 3.0 :: Flex Bitmapdata Hittest Bug (Error #2005)?

Oct 11, 2010

sometimes I get this extremely nasty bug:

Code:
ArgumentError: Error #2005: Parameter 0 is of the incorrect type. Should be type BitmapData.

[code]....

View 3 Replies

ActionScript 3.0 :: Flex Bitmapdata Hittest Bug (Error #2005)

Feb 22, 2012

sometimes I get this extremely nasty bug:

Code:
ArgumentError: Error #2005: Parameter 0 is of the incorrect type. Should be type BitmapData.
at flash.display::BitmapData/hitTest()

This is the line where I get this error:

Code: if (player.bitmapData.hitTest(player.point, 255, tempUpgrade.bitmapData, tempUpgrade.point, 255))

I have absolutely no idea what went wrong. My object (tempUpgrade) is generated inside of a manager-class. There I can define the look of it and it gets cached. The image I use is a spritesheet (png) that's embed inside of my library-class. The spritesheet is splitted into appropriate pics via a CacheTileSheet-class.After that process they get thrown inside of an array because I need the bitmapData for pixel-perfect collision detection. Of course this is not the complete code so if someone needs more please let me know.

[Code]...

View 6 Replies

Flex :: AddChild A BitmapData Or Draw A BitmapData To Screen?

Jul 15, 2009

I'm currently working on a flash game and I need to know how to addChild a BitmapData or draw a BitmapData to screen. If I can't than how can I give a DisplayObject my BitmapData?

View 2 Replies

ActionScript 3.0 :: BitmapData = New BitmapData(); Eating Up Memory?

Dec 22, 2011

I've made a mobile version of my software, with low-res images and such, and I can now fully buffer all my content (including a 360 frame animation which is buffered to memory). Problem is, that everytime I update the view, more memory is used.When I write image = new BitmapData();, does it store the previously created BitmapData's in memory? Do I have to flush the memory somehow before I draw my second picture in BitmapData?Example:

ActionScript Code:
// In this example I draw using the same bitmapData several times, also
//overwriting the first image. Do I have to somehow delete the data first, to

[code].....

View 1 Replies

Actionscript 3 :: Bitmapdata.hittest Collisions With Opaque/transparent Png Files Imported With Loaders

Aug 27, 2010

I have two png files. I import them using loaders. The images in the png files each have opaque (solid) and transparent parts. I want to use the bitmapdata.hittest method to detect when their opaque parts have collided.

[Code]...

I've been working on this for a couple of days now and nobody seems to know how to do this. Please don't post the examples on google, I've looked through at least the first five pages of results on google and haven't gotten any of them to work. The problem is that none of them provide an example of using this method with loaders, so I'm guessing the reason I can't get it to work is some gimmick associated with them.

View 1 Replies

ActionScript 3.0 :: Using BitmapData.draw(stage) - Error #2123 Security Sandbox Violation: BitmapData.draw

Jan 9, 2012

I am having an issue with using BitmapData.draw(stage). I am getting the following error:

SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: file:///C|/Documents%20and%20Settings/bla...bla...bla.swf cannot access null. No policy files granted access. Here is a portion of my code:

var bd:BitmapData = new BitmapData(2800, 2100); bd.draw(stage);//this is where the error happens All of the files referenced (.xml/.jpg/.swf) are located in the same local folder as the main .swf. How do I get around this error? The main objective is to print the stage using PrintJob(). I am using Flash Professional CS5.5 and publishing to Flash 10.0/10.1. Let me know if I need to supply any more info.

View 4 Replies

ActionScript 3.0 :: Bitmapdata.hitTest - Bitmap 'emptyBitmap' With Bitmap Data Created

Feb 3, 2009

I'm cutting my teeth in actionscript 3 on a game that has a character running through a world. So, I have set up my Hit Testing by using the bitmap data hit test method, since I figured my world is going to be destructible - it'd be nice to update the level and then redraw it and have the character interact with the new change. (That works beautifully) I am however; a bit confused as to how I have my hit Testing set up. I've been messing around with it, and it works for now - but I'm not sure why.. currently, I have a character set up by using a class I built and using a series of animations I created. So, this character has a walking and falling animation, etc. This is a movie clip.

Then there's a bitmap 'emptyBitmap' with bitmap data created - however; I never really added this as a child to the character. This is sized to the dimensions of my character. My level is created as a movielip, then it's drawn to a bitmap - when the level movieclip is changed, the bitmap redraws, and that's how this updates.

[Code]....

View 1 Replies

Actionscript 3 :: Graphic Object BitMapData Type The Same As BitmapData Type?

Dec 29, 2009

The title might be a little misleading. Look at my code and I will explain

public static function loadTile(tileDir:String = "empty"):void
{
if(tileDir != "empty")
{
tPoint = new Point(0,0);
tRect = new Rectangle(0,0,30,30);

[Code]...

I am trying to do tiling with sprites. I want my tiles to be interactive, so that is why I am using the sprite object instead of using regular bitMaps to represent my tiles. You might be wondering why I wouldnt just use graphics.beginBitmapFill(tImage); and graphics.drawRect(0, 0,tWidth ,tHeight ); to pick out the tiles I want to use. Well reason being is because it turns out that drawRect() first and second parameters actually alter the location of where the actual sprite sits at.

So if I set the x and y properties of the sprite to x = 20, and y = 20. then I set my drawRect(20,20). it actually adds an extra 20 pixels to my x and y coords of my sprite. And I know the reason why, I just need to know a better way.

View 2 Replies

ActionScript 3.0 :: HitTest() Point Of Collision?

Dec 4, 2009

I've found the BitmapData.hitTest() function very handy, but limited for my purposes. I need to figure out at exactly which point the two images collide  (in any coords system,really), since their behaviour will change depending on the angle of the surface hit

View 9 Replies

ActionScript 3.0 :: Hittest/Collision Detection?

Apr 18, 2012

I'm trying to create an animated 'LED style' display. I want to draw/tween/type shapes or text and have the 'LED dots' detect the animation and turn on the relevant dots.'ve been testing the hittests but it slows down pretty quickly and the problem with the hitTestObject is that it obviously just detects the bounding box, NOT the vectors.

View 3 Replies

ActionScript 2.0 :: Collision Detected <hitTest>?

Apr 3, 2004

I'm try to make the Collision Detected with hitTest for long time but it doesn't work. I have two objecct one is the Spaceship and rock. When those two hit each other. I want it to show text "Collision DetectedFrame1 script

var rockCount = 0;
var rockTimeGap = 1;
var nextRockTime = 0;

[code].....

View 3 Replies

Actionscript 3 :: Collision Detection Using Bitmap.hittest

Aug 26, 2010

I have two png files, a circle and a maze. Basically the maze is a square with some paths carved through it. I want to draw these images, move the circle to the mouse coordinates, and have a text say 'hit' when the circle intersects a wall of the maze and 'miss' when it doesn't. Now I want to do these using the bitmapdata.hittest method. The circle is a 32x32 image and the maze is a 256*256 image. I've gotten everything set up and everything draws on the screen correctly but I can't get the actual collision detection part of it to work, that is it always displays 'miss' rather than 'hit' even when the circle clearly intersects the maze.[code]

View 1 Replies

ActionScript 2.0 :: Make The Collision Detected With HitTest?

Apr 3, 2004

I'm try to make the Collision Detected with hitTest for long time but it doesn't work. I have two objecct one is the Spaceship and rock. When those two hit each other. I want it to show text "Collision Detected" This is my script

Frame1 script
var rockCount = 0;
var rockTimeGap = 1;
var nextRockTime = 0;
var startTime = getTimer();

[code]...

View 3 Replies

ActionScript 2.0 :: HitTest Not Working For Plane Collision?

Apr 4, 2003

I can't seem to get hitTest to work for the plane in my little game. The code I'm using in the plane MC is:

[AS]if (_root.player.hitTest("_root.badguy"))
playerhealth -= 20;
}

[code]....

I want to the badguy plane to hit the player's plane and take a subtraction from the player's heath. I've fiddled around with using "this" instead of the full path of the playerMC - no success. My hitTest is working fine for the bullets!

View 3 Replies

ActionScript 2.0 :: Collision / HitTest Never Returns True

Mar 10, 2006

For some reason my hitTest in the following function is not working. With each onEnterFrame of the mc being "fired", I am checking to see if it is touching one of the "clouds" I have floating by. My traces tell me that I am targeting everything correctly, but for some reason, hitTest never returns true. Even when I see the mcs colliding. The "clouds" are dynamically attached and pushed into an array (cloudsArr) The clouds and the "fire" mcs are on differnent timelines, but should that matter if I am targeting them correctly?

[Code]...

View 5 Replies

ActionScript 2.0 :: Use HitTest With Two Movieclips To Detect Collision Of The Visible?

Dec 12, 2002

Does anyone know how to use hitTest with two movieclips so that it would detectthe collision of the visible part of the MC, not the **** bounding box???

View 2 Replies

ActionScript 2.0 :: Generic HitTest - Detect Collision With One Object

Oct 13, 2005

Right now I'm working on an advanced hitTesting engine, and What I'm trying to do here is create an engine that will detect collision with one object instead of two. That basically means that if any other objects touch this movie clip, the hitTest will return True. Right now the .fla containing the engine has nothing but a circle that can be moved using arrow keys and 8 squares that disappear when touched by the circle. Obviously, I could do something like:

if (circle.hitTest(square1)) {
do so and so
} else if (circle.hitTest(square2)) {
do this and that
} etc...

But that would be too long, since the engine has to be able to contain 100 squares without too much change in the code.

View 3 Replies

ActionScript 3.0 :: Fail Hittest Collision Using Multiple Arraylist Objects

Jan 4, 2011

I'm actually working on a multiple collision detection in actionscript 3.0, using pixel collision for a game for my assignment, where an enemy patrols around and searching for the hero. So, i draw a line between the enemy and the hero, to check whether there's some collision happened between those two. if the line colllides with an obstacle such as wall, door, etc. enemy will not be able to see the hero. When i tried a single line collision with a wall (one object only) it works perfectly.

But here's the problem. For the multiple objects collision (several walls and doors included), i added those objects in an arraylist, When i used for loop to check the collision between the line and those objects in the arraylist, none seems to react , except the first object in the arraylist or index 0.

Is there any simpler way to do the multiple collision detection?

View 2 Replies

ActionScript 3.0 :: BitmapData To Video?

Jan 10, 2010

So due to my lack of time to research this and my strong curiosity for the matter:Does anyone know of any publicly available classes or ways to convert an array of BitmapData to a video format ByteArray (going to save it since I'm using it in an AIR project)?

I was considering writing my own class for it but started in the research and decided it's a very highly developed field and is hard to quickly find the basics of how to handle it. Thus it's usefulness outweighed it's opportunity cost for the time I have unless there is an already made class for handling this.

Mainly was considering this for short clips that one would create for logos etc so that one can display the logo in other environments with ease.

View 2 Replies

ActionScript 3.0 :: Which BitmapData Is Clicked?

Aug 4, 2010

I have a bitmap with a different bitmapData on it (done through copyPixel) and I was wondering whether there is built in function that can determine what BitmapData the user is clicking on? how to best figure out which BitmapData is clicked, or do I have to do x,y pos comparisons manually?

View 8 Replies

Professional :: BitmapData Objects And The GPU?

Sep 7, 2011

Are BitmapData objects automatically GPU accelerated for rendering, rotating, and scaling,or does the bitmap they connect to need to have cacheAsBitmap set to true?

View 1 Replies







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