ActionScript 3.0 :: Irregular Semi-Perfect Collision?
Jul 15, 2011
I have a bunch of different Movieclips from about 10 different classes moving about the stage. What would be the fastest/most efficient way to detect collisions between two of them? They can overlap each other a bit before the collision is detected, so I thought the easiest way would be to draw a couple rectangles that take up a majority of the object for each class and use hitTestObject to see if any of the invisible rectangles of one instance are colliding with the invisible rectangles of another. Is this a good method? I figured that since a bit of overlapping is okay and actually preferred, that two or three rectangles can easily take up all the room I need for each object.
View 2 Replies
Similar Posts:
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
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
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
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
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
Sep 12, 2009
I want to use semi-transparent mask on external swf for smooth transition. I'm using
clip.cacheAsBitmap = true;
mask.cacheAsBitmap = true;
clip.setMask(mask);[code].....
it doesn't work... what am I doing wrong?
View 7 Replies
Mar 25, 2010
Can you export a semi transparent .swf? I need to send a .swf file with 70 percent opacity that will eventually be an overlay over a video.
View 1 Replies
Jul 27, 2010
using action script how to draw a semi circle...i need to add tha semicircle in another circle the circle looks like this ![alt text][1] how to draw a semi circle inside that circle
View 1 Replies
May 3, 2009
I've been developing in AS2 for a few years now, and I'm learning AS3 at the moment. I ran into a problem about setting alpha on a PNG image.
I have a movieclip that holds a semi-transparent PNG image which comes straight from the library. Now I want to edit the alpha property of the movieclip. In AS2 it all works fine but when I set the alpha property in AS3 all semi-transparent pixels in the PNG image will fill with black first; then the alpha setting is applied.
Do I need to save my PNG's in particular way or do I need to edit settings in Flash to display correctly?
View 1 Replies
Jun 15, 2009
when you iterate through an array using for / each, assuming the elements in the array are primitive types, the looping var takes on the type and value of each item, but is not a reference to the item.
Code:
var arr:Object = {a:1,b:2,c:3};
for each (var a:int in arr) {
a++;
[code]...
This differs from the behavior of PHP5, for example, where even though most objects are passed by reference automatically, objects within foreach loops are treated as copies unless specifically passed as &references like
PHP Code:
foreach ($arr as $key=>&$b) {}
Is there any way to get AS3 to do the decent thing and give you a choice whether subarrays are passed as references or not, without resorting to making ByteArray copies of your objects for every iteration of a loop?
View 4 Replies
Feb 10, 2010
I am trying to find out if it is possible to a) create a semi transparent box in flash, b) motion tween that box into place, c) subsequently use it to run forms and PHP scripts (connect to a MySQL instance, ect). I know that an exact answer to c) will be long and complex, so a simple (general) yes or no will suffice... but if someone could point me in more detailed direction with a) and b), If you need to see the actual project I'm working on, or if I need to clarify my questions,
View 1 Replies
Dec 9, 2010
I am quite experienced in Photshop and other elements however I am an absolute novice when it comes to flash.
What I am trying to create is an effect for a logo in which the motif in a semi circle shape which i want to appear in a wipe fashion starting left to right so that in wipe across and the shape appears in full at the end.
The shape in a rainbow....this would also have the company name below the logo which would be visible from start to finish. I have attached the picture of the logo. I would like the gold pot to also appear in the swipe of the rainbow.
View 3 Replies
Aug 4, 2009
I'm trying to make a simplegame in which you have to avoid a bunch of angry looking circles as they move across the screen. What should happen is that they all spawn outside of the stage and move across it then when they reach the other side they appear from somewhere else outside the stage So far I have managed to only make them come from one side of the screen by using this script on the enemy
[Code]....
I've tried using a switch() function with a random number to choose which side the enemy comes from but that didn't work it just skipped to default
View 0 Replies
Oct 8, 2009
Once I have a semitransparent object (with alpha not equal to 1) and put a glow filter on it, the glowing area is visible not only near edges of an object, but also under the object. It changes the whole look of an object, while it (probably by my logic) only should have changed the look of edges.
how to glow (or drop shadow) only edges of an object?
View 2 Replies
Nov 19, 2007
I have a string that looks something like this: 00110; book1,book2,book3,: 6 What I need to do it spilt it up into sperate values by the semi colon. so in the end it would be like
[Code]...
View 13 Replies
Jul 1, 2004
I'm loading 10 jpg images into _root.content.section_4.mc_anim, each is placed into its own movieClip.
Code:
_root.content.section_4.mc_anim["gall_img_"+img_view_index]
These movieclips are hidden and then have the images from an array loaded into them.
[code].....
View 1 Replies
Feb 7, 2010
When I hit enter to play back my animation, it does not play at the 30 FPS at which I set it to. Instead, it ranges from about 15-20 FPS randomly going up and down throughout the whole animation. When I publish the animation as a .swf, it plays back just fine, at the normal speed. Just wondering why it's doing this, it was fine before.
View 5 Replies
Jul 15, 2010
I try to animate a Movieclip (box or circle) thru a half ellipse path. Circle or ellipse path will be random.
View 1 Replies
Aug 16, 2010
I'd like to add a couple of different MC's to the particle stream. I'd like to do that by referencing different items in the library.So I have 12 different particles in the library exported with classes named from Bubble0 to Bubble10 now as I run through my for loop I'd like it to use a different particle each time. first time I tried:
ActionScript Code:
var bubbleArray:Array = new Array();
bubbleArray.push(Bubble0,Bubble1,Bubble2,Bubble3,Bubble4,Bubble5,Bubble6,Bubble7,Bubble8,Bubble9,Bubble10,Bubble11)
for (var j:uint = 0; j < NUMBER_OF_BUBBLES; j++) {
[code]...
Scene 1, Layer 'actions', Frame 1, Line 871086: Syntax error: expecting semicolon before leftbracket.Is what I'm trying to do possible without some clunky switch statement?
P.S. I tried searching the forum for an answer but the terms are so common I couldn't find what I'm looking for.
View 6 Replies
Nov 22, 2003
are semi colons ever REQUIRED after function definitions? From my experience Flash's parser doesn't seem to be too picky.
View 9 Replies
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
Nov 30, 2010
I'm trying to make a modal pop up in my Flash application, not unlike the ASP.NET version seen here. I've already got the dialog box made, but I'm trying to add a semi-transparent gray rectangle over everything behind the pop-up, again like the one used in ASP.NET. Is there a way to do this in ActionScript? It needs to be semi-transparent, not fully, so you can still partially see what's behind it. I'm assuming you could apply this property to a Shape class somehow.
View 3 Replies
Apr 25, 2010
This is a snippet of my code which is giving me
1086: Syntax error: expecting semicolon before leftbracket.
What I'm trying to do is create a an array from the amount of "players" and then for each player in the array, add another array into each level of the array that has 3 levels which are all set to '0'. When I remove: var scoreArray[i]:Array = [0, 0, 0]; the error stops.
ActionScript Code:
public var players;
public var playerScoreArray:Array;
public function gameSetup() {
var playerScoreArray = new Array(players);
for (var i = 0; i < players; i++) {
var scoreArray[i]:Array = [0, 0, 0];
playerScoreArray[i] = scoreArray[i];
}}
View 1 Replies
Oct 3, 2010
I'm a bit boggled by a MouseEvent/layering problem.
I have a filled Shape, with alpha 0.5, on top of a Sprite. The Sprite has various MouseEvent listeners attached to it.
I'd like the user to be able to click on the Sprite. Unfortunately, Flash doesn't pass the events to the Sprite. (It does, of course, if the shape is unfilled.)
Is there any way to tell Flash to treat this object like an unfilled object, rather than a filled one, for the purpose of MouseEvents?
View 5 Replies
Aug 24, 2009
Currently I have link on an HTML page, and when the link is clicked, it opens a flash movie with slideshow and a semi transparent black background. The way I have it set up is as follows
CloseButton.as (the close button for the slideshow)
FullBackground.as (the black background)
MainContent.as (loads the slideshow)
then I have
main.fla (loads the CloseBtn, FullBG, and MainContent)
preloader.fla (loads the main.fla .swf)
View 1 Replies
Aug 14, 2010
What would be the best way to check if a user clicked on a sprite or movieclip if the sprite or movieclip contains irregular shapes.
View 2 Replies
Jul 5, 2011
I have maze-like game and I'm trying to get the player mc to respond to a collision between the boundary mc.hitTestObject doesn't work since it's not a rectangle. Is there a way to do this?
View 7 Replies
Jan 19, 2009
Can anyone tell me if I can copyPixels with an irregular shape instead of just a rectangle?
View 0 Replies
Apr 5, 2010
I have a pair of triangular movieclips that are up against each other real snug and are practically touching. As a result their bounding boxes overlap so using onPress for them causes the one on the higher depth to be clicked. How do I use onPress to mathematically determine if the cursor is within some boundaries I set?
View 1 Replies