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


Similar Posts:


ActionScript 2.0 :: Collision Detection To Be Based On Movieclips?

Dec 2, 2002

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.

View 14 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.0 :: Tile Based Game - Creating Multiple Sprites Based On Frames

Nov 17, 2009

I'm relatively new to AS3. There's one thing that I don't quite understand about Sprites. I'm making a tile based game, and all the tile graphics for a level are inside one movie clip in each frame. Would I be able to go about creating multiple sprites based on the frames in said movieclip's timeline I would I have to go through and make a separate library graphic for each.

View 2 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. 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 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

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 :: Build A Tile-based Map In Flash?

Feb 24, 2012

[code]...

This is my code so far, is square.graphics the way to go? How do I draw a tile that is a picture? Do I need to hold the graphics in some sort of array to do checking like collision?

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

Flash Development On MacOSX - Build A Tile Based / Platform Flash Engine?

Mar 7, 2010

I'm familiar with C/C++/Scheme/Java/OpenGL/TCP/IP.I need to learn how to build a tile based / platform flash engine.What tools should I be using? What books should I buy?I strongly prefer tools that let me do things programatically rather than through a graphical UI.

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

ActionScript 3.0 :: Collision Detection - Use HitTestObject?

Oct 28, 2010

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?

View 1 Replies

Actionscript 3 :: How To Do Collision Detection For Hollow

Apr 19, 2010

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?

View 2 Replies

Actionscript 3 :: Collision Detection Is Not Recognized?

Feb 22, 2012

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!

[Code]...

View 1 Replies

ActionScript 3.0 :: Too Many Objects For Collision Detection?

Sep 16, 2009

I have Object "A" that moves around and collides with other objects. There are hundreds of other different objects it can collide with. The only way (I found) to test for collision is to loop through every other object. That seems rather inefficient considering I don't even know how many objects exists. Other objects are constantly created and deleted. So this loop would be rather complicated.Is there a way for object A to receive what other object it collided with so that I can then do some code on that other object. Any way to avoid looping? I later need to find out how to detect what objects are near (within x pixels or so) of object A to decide with which one to interact. Maybe that could also be used now to limit the test of collision? Or maybe it gives someone an idea of what to try?

View 4 Replies







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