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.
I am in the process of building a project in which several MovieClips "swim" around semi-randomly, and another MovieClip that appears and expands over the mouse on click alters the frequency of the turns. Do do so, I simply need to change the value of a single variable on the first MovieClip's timeline when the two collide. I am using hitTestObject, but I keep running into errors. The expanding MovieClip does not have an instance name, because it only appears when the mouse is clicked, and quickly disappears.
I am receiving the error 1067: Implicit coercion of a value of type Class to an unrelated type flash.display.DisplayObject My code causing my first MovieClip to "swim" is on that MC's timeline, while the rest of the code is on the main timeline.
is there a way to do collision detection amongst identical movieClips? The movieclips have all been added to the stage from one symbol in the library using AddChild().I've attempted to create 2 different arrays for them and push them into each array as they are added to the stage so that there was a means of comparing them. When I perform the collision detection, Flash thinks that the movieClips are in constant collision with each other!I used trace ("bang") to test the collision, and the output window starts tracing "bang" infinitely and doesn't stop, and none of the movieClips are touching each other.
Next I'm going to make a game with ball physics on it so if anyone can tell me how to make ball physics with bouncing from angled objects.Also, I need the collision detection to be based on movieclips because I need to be able to modify the levels in the game.
I was wondering how to have collision detection between two differente duplicated movie clips. For example, a duplicated bullet hits a duplicated bird, how do I make it so that it detects collision when the duplicated bullet(bullet+x) hits the duplicated bird(bird+x)?
I have a movieclip (myMC) that I create several instances of.I dont duplicate the movieclips, but just copy and rename them like "myMC_i", where "i" is a unique number.Can I somehow check if one copy of myMC (for instance "myMC_2") collides with another copy (for instance "myMC_5"), always ignoring collisions with other types of movieclips on the stage?Thats the problem I cant solve. I can either check for a collision with ANY other movieclip, or check for a collision with a single SPECIFIED movieclip (by checking for its name). But I dont know how to check for a collision with a group of movieclips that has the first part of their names in common. If it had been like in a search-engine, you would have been able to search for:[code]
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.
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:
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.
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.
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.
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.
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
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
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 :-(((( )
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.
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();
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?
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?
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?
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.
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.
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]
HitTestObject seems to check collision of bounddaries of shapes, it seems to consider everything rectangular. Also if one object jumps two pixel and other five pixels on EnterFrame it seems like there won't be any hit detection. Seriously guys what else method do you use, if you use hitTestObject how do you use?
I'm making small interactive games in flash to learn AS3,I need to check the collision between the player and the wall which is normally simple using the hitTestObject function.But now I made a wall object totally surrounding the player with corridors and turn, a collision playground so to speak. Now when I use the hitTestObject function to check whether the player is in collision with the wall it tells me it always collides supposedly because the player object is within the bounds of the wall object.So assuming that I'm correct about the error:How can I prevent getting a collision when I'm inside the bounds of the wall object but not touching the actual walls in that object?
I'm trying to make a game like Mario. I've made a character which can jump right now, but I've got some problems with collision detection.
I would like my character to jump on a bar, which is placed higher. My collision detection doesn't work at all I gues..I've made a cirle which has a instance name mcMain and I've made a MovieClip of it. T also made a rectangle which has a instance name balkje, I also made aMovieClip of it.
I hope you can tell me what is wrong about my code and what I've to change to make the collision detection work!