Flash :: Collision And Bounce Detection From Array Of Points

Sep 18, 2011

I have an array of points that I will use to generate a closed polygonal fence on the outside of a game stage (2D). I wish to have collision detection between this fence and a bouncing ball-like object on the inside. Additionally, I would like to be able to arbitrarily add/remove/redraw the fence in realtime and have the collision detection still operate realistically. I have considered drawing a Sprite/Shape from the points and doing a HitTest at each frame to check whether to bounce or not. My question: is this the best/correct way to accomplish this goal? Consider something like JezzBall with diagonal lines of any angle a simulation of what I'm trying to do.

View 2 Replies


Similar Posts:


Collision Detection And Bounce Physics?

Jun 15, 2011

I need help with one of my Flash projects,I'm trying to use gskinners shape based collision detection, but for some reason I cant get it to work, but im pretty new to using classes, so I dont understand the structure too much. Can i get a tutorial on how to use the gskinner class? im using the as2 version.heres the code, bare with me, there's a lot here. in all codes, mc1 is the track outline MC, and mc2 is the car

basicly im making a 2D top down version of WipEout HD Fury, so file structure is something like this (the .fla is called wipeout as3 because i was initialy coding in as3 and never changed the filename).wipeout as3.fla (the flash file containing all the MCs and animations, but only enough coding to import all of the external code files, as well as the VCam and its script)
the code is;

Code: Select all #include RaceControl.as"

the RaceControl.as is used to determine the Car's control scheme, and refers to a physics code called RaceCar.as. i found it on the interwebs, all credit to matt carpenter;

Code: Select all// Race control

// Create key listener[code]........

the Bounce Function is my own work, and is what i want to happen when a collision is detected.now, the movieclip used for the car is my own drawn design, as is the track, and i want to use GSkinner's shape based collision to detect the collisions properly. so far i have the car driving around quite happily but i need it to collide with the walls of the track, rather than drive right through them.

View 1 Replies

Arrays :: Flash - Collision Detection Between An Instance In Motion And Array Does Not Work?

Mar 8, 2012

I am trying to test the collisions between a bullet and an array of enemies in Actionscript 2. However it is not sensing a collision.This is the code in the bullet.

onClipEvent(load)
{
facing = _root.player.facing;
speed = 1;

[code]....

View 1 Replies

ActionScript 3.0 :: Collision Detection Array Object?

Mar 28, 2012

I'm trying to have an enemy's shell hit my player. I have the logic in place that detects a player's bomb hit an enemy, I tried to edit it slightly and apply the same logic to the enemies shell.

Code:
// check for collisionspublic function checkHits(event:Event)
{

[code]......

View 2 Replies

ActionScript 3.0 :: Multiple Array Object Collision Detection?

Jun 23, 2009

I am creating a game where I have two separate arrays of objects that I need hitTested with each other. I found an old tutorial in AS2 that I modified to come up with this code:

ActionScript Code:
for (var w:Number = 0;w < enemyLaserArray.length;w++) {
for (var R:Number = 0;R < barricade1Array.length-1;R++) {
if (enemyLaserArray[w].hitTestObject(barricade1Array[R])) {

[code]....

This code executes like I believe it should, but along with removing the two objects, and splicing them from their arrays, I get this error

Code:
TypeError: Error #1010: A term is undefined and has no properties.on the line hitTestObject line. I have had similar problems in other areas of my project, but this time no matter what I try using trace statements I cannot fathom quite what the problem is.

View 2 Replies

ActionScript 3.0 :: Collision Detection For Array Objects In A For Loop?

Nov 13, 2009

a little while ago I saw something on this website:[URL]...I decided I wanted to recreate something like it.

They're using javascript, I'm using ActionScript, anyway.I'm trying to create collision detection for an array of movieclips inside a for loop. Right now I have it that upon holding down the mouse, the same movie clip will fall onto a ground object (and bounce up occasionally,) I'm trying to make it to so each ball could stand on top of each other. I've used collision detection before for separate objects, but never for instances of the same object inside a for loop.

View 0 Replies

Actionscript 3 :: Collision Detection For Loop Only One Array Item Tested?

Apr 2, 2011

[I apologise if this isn't really an in depth question, but I wanted to solve this once and for all]I was trying to get look into quadtrees, but already ran into trouble getting collision detection without any optimization working properly. Did a search and found a pretty neat example:Only some collisions are detected between particular objects. When the objects are not moving it seems to work alot better for some reason. really can't figure out whats the problem, the code is essentially the same as the sample. I did not blindy copy pasted it, I understands whats happening except Here is what I did:Main class

package
{
import com.martino.objects.Square;

[code]....

View 2 Replies

ActionScript 3.0 :: MovieClip Collision With Points Stored In An Array?

Jun 8, 2011

Im a bit stumped on this. I have a movie clip named mcMain that the player controls, and i want him to have it detect collisions at certain points of the screen (like at a certain X and Y co-ordinates). I have an array that contains those values, which is shown below:

Code:
//Array that holds x position of points
var xPoint:Array = new Array(150,400,200,300,100);

[code].....

View 3 Replies

Collision Detection Incorrectly Detecting Collision?

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

Actionscript 3 :: Pixel Collision Detection For Flash

Jan 11, 2010

I was told the pixel detection is costly for regular windows games. Is this the same for flash ?? Or would pixel detection be lighter compared to other detections flash has to offer. Flash has the getPixel32 method which makes it easy for detecting pixels. If I am bliting my game, would it be wise to use getPixel32 for collision detection. Or should I just check for specific tiles?? Is getPixel32 limited to the display object it is in ?? In other words, can I detect any pixel regardless of what layer it is on in the display list.I probably can figure this out on my own but I want to ask first to save me some time. But does anyone have any code or good sources on how to go about doing this if it is reasonable.

View 6 Replies

AS3 :: Flash - Continuous Movieclips With Collision-detection?

Mar 8, 2011

I'm starting to understand ActionScript and getting better with it. However, I'm building a platform game with an unlimited length. What would be the best way to create the "block" the player is jumping on?

Of course collision detection for these movieclips is needed (nicest would be to do it without a giant loop through an array, etc. on every frame). There's probably something like 5 block on the screen at the same time.

View 2 Replies

Flash :: For Each Loop And Collision Detection In Actionscript 3

Jun 11, 2011

I am in the progress of making a Flash game and currently I am doing the coding for collision detection. The collision detection will be for detecting if the player is running into obstacles, and if the player runs into the obstacle, then it will stop him from running through it. Here is my code that I am using for collision detection:

[Code]...

View 1 Replies

Actionscript 3 :: Flash - Optimizing Collision Detection

Oct 25, 2011

I'm trying to make my first game in Actionscript 3. Its a simple artillery game where you have a gun at bottom left corner and AIs flying across the screen which you have to shoot down. Now, in a classing shooter game how this is achieved is either by firing a bullet from the gun and doing a hitTest of that bullet with the AI movieClip or by simply removing(or playing the death animation) the AI movieclip. But here's the problem. I dont wanna do either of them. I want to show a gun with a rapid fire rate and hence no bullets. And I also don't want the player to click exactly ON the AI movieclip to destroy them (just the gun/turret pointing at the correct direction should be enough). So here's what I tried. This image should help picture the whole thing.

Tried attaching a 'line' to the turret and checking for collision with AI clip. This obviously failed because of the bounding box problem when the line is slanting.
I tried putting multiple tiny movieClips ON the line and iterate through them in a loop and checking for any collision with the AI. This method partially worked, but it was too slow and didn't seem like the 'correct' method. I draw 2 hypothetical lines. One between p1 and p2 and other connecting p3 and p4 (please see the image above). p3----p4's lenght = AI.width and is a horizontal line running right through the center of the AI MovieClip. Upon mouseClick I check for any intersection between these two lines. Now if I have multiple AIs on the screen, Again i need to iterate through each of them, draw a fresh p3-----p4 and check for intersection with p1-----p2.

[Code]....

View 1 Replies

Flex - Collision Detection Flash Builder?

Nov 23, 2011

I am having trouble with getting some code dealing with collision detection to work. I have tested to ensure that it does detect the collisions, and it does, however I am unable to get it to work as it just walks through the block. I also tried just taking away -10 from the x value after it collides but it will stay for the first couple of tries then just walk through the block.

private function collisionDetect(evt:Event):void{
if(IMG3.hitTestObject(block)){
if(IMG3.x > block.x){
IMG3.x = block.x-1;
}
}
}

View 1 Replies

ActionScript 2.0 :: Collision Detection For Flash Game

Jun 7, 2011

I have a movieclip called nest, which also contains a movieclip called wall. The bullet is created in the nest movieclip, and I am trying to make the bullet disappear when it hits the wall.The problem is, when the bullet is at B, the hittest succeeds when there is nothing at b. [code]The bullet just passes through the walls.

View 2 Replies

ActionScript 2.0 :: Multiple Wall Collision Detection In Flash CS3

Feb 26, 2010

I'm using Flashcs3 in AS2.[code]My character gets stuck in walls and slows down trying to get out, also, hes about 10x faster now. any suggestions? Im working on a flash overhead shooter, multiplayer only. and I need the script to work so there can still be a bullet collision on each wall and not to be able to walk through it.

View 6 Replies

Flash :: Collision Detection In A Tile Based Enviroment?

Feb 11, 2010

I am having problems with my collision detection. basically when I hit a solid tile my character's body is half way in the tile already. here is my code.The properties wY and wX are my game world positioning. Not the stage positioning. dx and dy is the velocity the character is traveling. This first snippet of code is within a game loop. The focus point of my character is centered on the x axis

package com.objects
{
import flash.display.MovieClip;

[code].....

View 4 Replies

Flash :: Collision Detection. Rotating And Hiting At The Same Time?

Feb 23, 2010

What I want to do is rotate the object and have its collision box rotate with it. I want the rectangle to rotate so it looks like a diamond and have one of its sides hit the object in a per pixel fashion. From my reading of some books and websites it seems that normal rectangular collision and hitTestObject collision won't do for this problem. I have searched high and low and want to know if anyone has a solution to hit detection with moving and rotating objects. Here is my current collision code with rectangles

colboxrect = colbox1.getRect(this);
robotrect = robot1.getRect(this);
if(robotrect.intersects(colboxrect))

[Code]...

View 1 Replies

Actionscript 3.0 :: Flash - Sphere To Rectangle Collision Detection?

Apr 19, 2010

for the past two weeks I've been working on coming up with a collision detection system for my game in flash CS4. No matter what I try for some reason I just can't seem to do it, and I don't know how to fix it. This has never been an issue for me, I would even settle for basic rectangle to rectangle collision if I could, but no matter what I do I end up screwing it at all up. Somehow the collision detection either doesn't work at all, works for one side and jumps the guy through the wall on any other side or I think at one point it worked for two sides as long as I didn't hold down more than one movement key.

I've constantly scrapped what I've done over and over, right now I have no source code to present. I'm totally lost and confused, and my deadline for getting this done is today in a few hours. I really wanted to figure this out on my own but honestly I just don't see what I can do, I've got sphere to sphere collision detection working perfectly for my player and other spheres, but the walls are squares lined up to form long rectangles, and I just can't seem to get it to work. I'm dynamically loading the square-wall blocks as tiles to form a dynamically loaded map, and then I'm iterating through each individual block to determine if collision has occurred with the player. I think somehow I'm not managing the results right, or maybe I somehow need to be able to determine which direction the player hit the wall from, but I just don't know how to do it.

I've been staring at the screen for the past 3 hours trying to work something out but nothing is coming to me, example from a flash-type game or something similar I would be very grateful! (I've done this countless times in C++, C#, and java. I don't get what is going on in flash :-(((( )

View 2 Replies

Flash :: Collision Detection Between A MovieClip On The Timeline And One Drawn?

Jan 19, 2012

I'm making a program that lets the user draw shapes on the screen with the mouse. When they're done they press a button to finish. The user is only allowed to draw on a certain area of the stage, to control this on the timeline i have a movie clip that takes up all the space the user isnt alowed to draw in.When the user presses the button i want the programe to check that the shape the user drew isnt touching the moiveclip. I want it to do this without taking the border of the movieclip into account so i cant use hitTestObject()

heres what i have so far:
//------------------------------DRAW SHAPE------------------------------
private var shape:MovieClip = new MovieClip();

[code]....

View 2 Replies

ActionScript 3.0 :: Flash Very Basic TileBased Collision Detection

Sep 4, 2010

So I've never dealt with collision detection since I mostly have just made simple web-designs, apps, and things that just don't make use of physics or anything like that. But today I decided to fiddle with it a little and was pretty excited when I started out just using a square to move around with keys and so I made some walls to figure out some collision stuff.

And basically, I can't move out of the wall once I collide. I know I could make it so when I collide the sprite backs off a few pixels, but it causes that jittery effect. So I was wondering is it possible to check for a collision before the block is animated?

[Code]...

View 1 Replies

ActionScript 3.0 :: Flash MovieClip - HitTestObject For The Collision Detection

Apr 28, 2011

I have a bullet object and a boulder object (both movieclips originating from JPEGs) in my AS3 game. The trouble I'm having is with hitTestObject for the collision detection, as it's taking in to account the transparent areas and basing the collision on the bounding boxes surrounding the movieclips. This is a problem because the collisions are not accurate and if the bullet (long and thing line shaped) is at an angle...the bounding box is quite large around it...and it's "colliding" with the boulder even though it's visibly many pixels away. Is there a way to detect MovieClip collisions that ignore transparent areas?

View 2 Replies

ActionScript 3.0 :: Flash : Collision Detection Between Character And Platform?

Aug 10, 2011

whenever I start my game my character just falls through the platform. No Compiler errors are appearing, and there's nothing in the outbox. I'm pretty sure it has something to do with my character not knowing that it must land on the platforms, but how would I write that?

View 2 Replies

ActionScript 2.0 :: CS3 Collision - Make The Balls Bounce Off Eachother

Oct 11, 2009

I have a MC (a ball) with this AS on it:

[Code]...

This bounces the ball off each 'wall'. how to add more balls (using actionscript - ie not copying and pasting on the stage) and to make the balls bounce off eachother too?

View 1 Replies

ActionScript 2.0 :: Simulate Collision Of Block And Bounce Like Ball

Oct 12, 2004

I make this simple system to simulate a collision of a block in "walls" and bounce like a pong ball. To use drag the orange square and release to start the movement. But I have a problem, sometimes the collision not happen and the block go through the walls, I try less the time of setInterval that verify the collisions but not solve my problem.
collision system -> [URL]

View 3 Replies

AS 2 :: CS3 Collision Detection Ie Hit Test

Jun 21, 2010

Im currently working on a demo flash game built on AS 2.0. im a very beginner to this flash and AS and im stuck up with a very silly concept though im not able to overcome it. the problem i have is with collision detection ie hit test and im really struggling with it.

[Code]....

View 1 Replies

Actionscript 3.0 :: Collision Detection Kit?

Oct 16, 2010

Im using CDK, and I want to exclude color black.im using this: __collisionList.excludeColor(0x00000000);

View 5 Replies

IDE :: Easy Way To Do Collision Detection?

May 3, 2009

Its been many years since I've used flash and I was just wondering what the easiest way to do collision detection was now. I know that there was some hit test bounding box stuff present earlier but I don't know the capabilities of flash cs4 and the advances that have been made. Google searches have yielded things like complex pixel-perfect collision detection but not a lot seems to have been written about CS4 yet.

View 3 Replies

ActionScript 3.0 :: Get Some Collision Detection Working

Mar 19, 2009

I am trying to get some collision detection working. What I have is a ball moving around the stage. There is a box in the middle which when the ball hits, I would like it to bounce off the box. I can get the x axis working fine using hitTestObject but when I detect for collisions on the y axis, the two axis conflict. Does anyone have a way of doing this properly?[code]

View 4 Replies

ActionScript 3.0 :: Best Way To Do Quality Collision Detection?

Aug 25, 2008

So I've been googling around for information on detecting collisions in AS3 and I found this page which has what troy claims to be a 'pixel-perfect' collision detection algorithm:[URL]..

[Code]...

View 1 Replies







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