ActionScript 2.0 :: Any Way To Check Collisions By Arrays?

Apr 16, 2010

I am trying to apply code to all instances of the enemy that appear randomly but I've run into problems. Firstly the enemies appear when you press space and the collision doesn't seem to work. I kind of thought you have to push the enemies into an array and hitTest that array right?

Actionscript Code:
stop();
var ship_speed:Number = 10;var lazer_speed:Number = 20;
var enemy_speed:Number = 8;var lazertimer:Number = 0;
var basicenemy:Number = 0;var enemytime:Number = 0; var enID:Number = 0;
var enemies:Array =[]onEnterFrame = function() {
[Code] .....

View 8 Replies


Similar Posts:


ActionScript 2.0 :: Accurate HitTesting Updating Arrays With Collisions.F8 CS3.zip?

Apr 25, 2008

I have 4 ball movie clips, a playhead and four target movieclips called mc_1-4, the array, (my_array), has 4 elements, which are each defined as having values of 0: I have a hitTest set up that will trace my_array to the output window each time it hits mc_1, to see what is happening. However the hitTest prints the array 3 times?

Am i right in thinking that this is because the hitTest is being triggered on entry of mc_1 in the center and upon exit?I need to make this hitTest be triggered once when the hitTest passes the center of mc_1. Secondly if any of the balls have been dragged and dropped on to mc_1 i want the array value with an index of 0, to change to 100 from 0 (not in terms of its index position because my array is only 4 elements long, in terms of its actual value) which i have tried to implement but i cannot configure the right code.

1. hit tests that only trigger once when they pass through the center of the object thus tracing one array.

2.use the balls 1-4 to make the array index 0, have a value of 100 if they are in contact with mc_1.

View 4 Replies

ActionScript 1/2 :: Use The HitTest Function To Check For Collisions

Apr 17, 2009

I know you use the HitTest function to check for collisions, but how would I do that the moment a movie clip is dynamically created. So the moment the clip is created it would check if it is overlapping another clip. Also, does it matter if the clips are at different depths?

View 1 Replies

ActionScript 3.0 :: Flash Classes, Collisions And Functions - Check If A Ball Is Hitting Another?

Oct 11, 2010

Im working in FlashDevelop on a 'breakout' game where you control a paddle with your mouse and a ball bounces around the screen and breaks blocks.Right now I have a Main, Paddle, and Ball class. In the main class I added a Paddle called player as a public static variable. In my Ball class I have a collisionCheck() function. This way I can access 'player' from within my Ball class for testing collisions.

At somepoint in the game there will be a powerup that adds mutiple balls to the stage. Right now I have a function in the main class call addBall() to add a new Ball to the stage.I am now running into trouble. Working on the collision check method in my Ball class, I dont know how to check if a ball is hitting another ball because as of right now, balls are being added with the addBall function, so they can't be declared as public static variables.

View 1 Replies

ActionScript 3.0 :: Managing Multiple Instances - Assign The Bullet Speed And Check For The Collisions With Enemies?

Sep 17, 2011

I have been reading these forums for like 2 months, thus i never felt like being able to post something as a valuable answer to someone's problem, since i've been AS3ing for like 3 months now. I have a small problem here on a game that i am trying to create. I am trying to make a shooter game . Like the ones u kill enemies and then the the level advances ( imagine the pseydomovement depth feel of the background giving the player the taste of further movement of the field , yes like old airplane games ). Ok to the point.

1) created a main .as where all the code is running. The movement of the player is written there also. no problem with that. 2) created a bullet class where i assign the bullet speed and i check for the collisions with enemies. the problem occurs somewhere here i have created a statement where every some time ( like 0,5 secs ) an enemy appears and takes a random road till the stageHeight . here is the code .

[Code]...

So when all 5 mikros are out i start firing them . BUT only the last child of mikros seems to follow the hittestobject procedure of my code. Which means that if all of the 5 mikros are on stage the one with the smallest .y value will disappear when hit by "sfera". I know it is huge but this pains my head for like 1 week and i cannot think anything . Tried some staff. but i do not know if this is proper thinking or if my programming is proper for this and i must redo all.

View 1 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 2.0 :: Check Contents In Arrays?

Oct 10, 2007

I'm trying to do a memory game and the problem I have is I don't know how to check the contents in the arrays.[code]...

View 3 Replies

ActionScript 3.0 :: Check If Two (rather Complex) Arrays Are Exactly The Same?

Mar 28, 2009

I need to check if two (rather complex) arrays are exactly the same. I know that I can simply loop through everything & set a flag in case something is not the same, but I was wondering if there would be some easier way than this using a pre-built method?

View 11 Replies

Flash :: Arrays - As3 Check To See If Item In Array Has Been Clicked

Jun 29, 2011

Sorry if this is a little n00b-ish. I'm working in AS3. I've got an array of 8 buttons. I'm currently hiding the button that is clicked using e.currentTarget. How can I tell flash to make all the buttons that aren't the currentTarget to become visible (i.e. if a button has been hidden by previously being clicked, how do I tell it to become visible again when another button is clicked?)

[Code]....

View 1 Replies

ActionScript 2.0 :: Check If Any Duplicate Arrays Exist And Remove Them From MainArray?

Jul 7, 2009

I have a script that creates arrays based on certain events. These are all stored in one main array like so: mainArray = [[3,6,5,1],[4,5,6],[5,3,5],[4,5,6]]; As you can see, sometimes I end up with duplicate arrays within the mainArray. How can I check if any duplicate arrays exist and remove them from mainArray?

View 4 Replies

ActionScript 3.0 :: Arrays & Loops - Can't Get To Check The Rest Of The DataInputs And Toggle Their Circles

Oct 14, 2009

Inside each dataInput is a button that sets the var "varSumNum" to 1 or 2, retain or dismiss respectively. If I set varSumNum to 2 the retain button will hide the corresponding circleMC, but the circles need to toggle visible/invisible individually. This works fine on circleMC1, but I can't get it to check the rest of the dataInputs and toggle their circles. To clarify further, it needs to check each dataInput and if 2 & 4 are set to 1 circle 2 & 4 are removed.

[Code]....

View 21 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

Arrays :: Flash - Pushing Or Adding Arrays As Values Into A Multi-dimensional Array?

Jan 21, 2011

I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:

var slideDataArray:Array = new Array();
var slideShowDataArray:Array = new Array();
slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........


I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.

View 1 Replies

ActionScript 3.0 :: Arrays Of Arrays / Data Providers And Dictionarys

Aug 26, 2009

I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.

View 5 Replies

ActionScript 2.0 :: Flash Car Collisions / Hit Test

Sep 5, 2010

I've been using flash for a long time. I know some stuff, but not enough for what I am trying to do. Basically, I am making a little car minigame of a car in a city. This is my engine on the car:

onClipEvent(load){
speed =0 ;
} onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
speed += 0.4;
} if (Key.isDown(Key.DOWN)) {
speed -= 0.1;
[Code] .....

I am fine with all of it but the collisions, as the car will only bounce when the registration point of the car collides with 'wall', so it looks all funny and that and the car goes into any thing collable half way then bounces back, and occasionally gets stuck in the wall. Reall annoying. Ive tried fixing it but whenever I remove the hittest parts the car wont even move or turn. How to get the wall collides with the car (27.7 x 13) and not the registration. I need a strong engine which works with curves as well, and requires me just putting the code into the car, but if I have to put it into the walls/frame i suppose its okay, but theres no way im going through every single building and that.

Also, it would be cool if:
-An engine where when reversing the steering is reversed (like irl)
-The car doesnt bounce backwards when driving at a wall at an angle, but slides against it (like irl).

View 9 Replies

Actionscript 3 :: Detecting Collisions In Flash... Or A Better Way Of Doing It?

Jan 4, 2011

I'm trying to create a air-hockey game, in flash using AS3.At the moment, I am using an enter frame function to check the positioning of the 3 objects, 2 paddles and a ball, then it checks to see if they are in contact, if they are it then initiates a detect collision function.However it's checking every time the frame is loaded, and at 25 fps, this is quite a lot and the app lags.

View 3 Replies

ActionScript 2.0 :: Psuedo 3d Collisions Using Spheres

Feb 29, 2004

I'm having a bit of trouble with psuedo 3d collisions using spheres. I'm using _xscale and _yscale to emulate the z-axis (no horizon point), and am having trouble determining the distance between the objects on the z-axis based upon their relative scales.I'm not concerned at this moment with creating new vectors based upon hit angles, just getting the z-index collision detection working. (I also need to tweak the code to prevent trapping, so much todo)Here's the code, the issue is how do I determine the correct value for the z-axis in the hittest?note-this only works when I publish in flash6 when using mx2004, the collision detection doesn't work at all when published for flash7?[code]

View 7 Replies

ActionScript 2.0 :: Test Collisions Than HitTest?

Mar 15, 2007

Is there any faster way to test collisions than hitTest? I remember an example here on kirupa, but I can't find it.

View 1 Replies

ActionScript 2.0 :: Velocity - Collisions At An Angle

Aug 14, 2008

I can sorted Vertical and Horizontal collision. But I'm having trouble with collisions at an angle, e.g. a 45 degree ramp. My cousin says I have to work out the trajectory angle from the Xv and Yv but the closest I can get is:PHP Code:

[Code]...

View 2 Replies

ActionScript 3.0 :: Undetected Collisions In Loop?

Feb 9, 2009

I've been experimenting with circle vs. circle collisons. Ive been using the code below to check for collisions and seperate the objects.It works just fine, except in conditions where more than two circles are touching at the same time. For example, if three circles or more are colliding at the same time, they can sometimes overlap and then struggle to separate.

I think I know why this is happening. The code loops through the object array and checks for a collision between each object one at a time and alters their positions and velocities. The problem is that if it finds a collision between objects at the end of the array, the positions of the objects could be changed in such a way that they cause an overlap with an object that was checked earlier, for which no collision was detected. This new collision then goes undetected and this flaw is amplified when the loop runs again.

Code:
function circleCollision(circleOne:MovieClip, circleTwo:MovieClip):void
{
//Find radius, x and y positions of circleOne
var circleOne_Radius = circleOne.width/2;
var circleOne_X = circleOne.x;

[code]....

View 3 Replies

ActionScript 3.0 :: Break Out Clone Collisions

Mar 20, 2011

Im trying to make a breakout clone which I have working however I cant figure out how to test which side of the blocks the ball hits. I woul like to have a different reaction if it collides with the right side than if it hit the bottom etc.

View 2 Replies

Flex :: Detect Visual Collisions Between Objects?

May 3, 2010

I would like to avoid the tags overlapping each other in this small Flex project: I've this small FLEX project: [URL]..

The items are LinkButtons. How can I check if they are colliding or not ?

View 1 Replies

Flash :: Using A Custom Event To Listen For Collisions?

Feb 13, 2012

I'm new to flash and programming in general but am learning it to make games. I'm currently messing around with hit detection and its not to hard to test in the game tick ( fired from onEnterFrame). What I'm wondering is if it would be possible / useful to create a custom event that i can listen for. And make the eventListener hear when a collision happens. Also would this be better or worse for the cpu than testing the collisions of lots of enemies on a screen?

View 2 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 :: Avoiding Class Collisions / Overwrites

Dec 30, 2009

I'm working with AS2 and running into a problem when loading a bunch of SWFs that share classes. I have a main SWF that loads several child swfs. The main and the children often share some core classes. The issue is that these SWFs were not all created at the same time, and some of the core classes have changed between SWF compilations. It appears that the first instance of any class to load gets used for all following references to that class - regardless of which version of that class was used in compiling the following SWFs.In AS3, the ApplicationDomain can be set to circumvent this issue, is there any that can be done in AS2 to avoid this collision/overwriting?

View 9 Replies

ActionScript 3.0 :: Detecting Collisions For Different Parts Of Single Mc

Feb 6, 2010

I have a movie clip 'Player'.I want to divide the mc into two equal halves p1 and p2 for collision detection (p1 and p2 are joined together physically).i.e. if ball collides with p1, i do something and if ball collides with p2, i do something else.But i dont want to create 2 different players p1 and p2 for that.i want to have something like p1 and p2 are a single movie clip 'Player', but still can be accessed separately.

View 6 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 2.0 :: Draw Lines And Detect The Collisions?

Oct 22, 2007

I am looking to create a drawing component on a site. that should be straight forward.the issue lies with the fact that I would want to detect any collisions say (4) and then attach MC's to the collision points.in a nut shell.can I get a trace of the drawn path on the stage?????from there I guess I can detect any positional similarities?

View 8 Replies

ActionScript 3.0 :: How To Stunt Pilot-esque Collisions

Sep 4, 2010

I know how to do various types of collisions and also know how to scroll a background. I'm sort of having trouble putting two and two together for how a game like stunt pilot knows if a plane has gone through a ring vs hitting it... It's for an iphone game (objective c w/ sparrow framework) just I figured it would be easier to figure out in flash then I can bring that knowledge over to my iPhone

View 1 Replies

Arrays :: Fastest Way To Merge Multiple Arrays?

Sep 26, 2011

I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:

var ar1:Array = [1,2,3,4,5,6,7,8,9];
var ar2:Array = ['a','b','c','d','e','f','g','h'];
function merge(...multi):Array[code].....

Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.

View 3 Replies







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