ActionScript 1/2 :: Collision Mask For Objects In A Game?
Sep 15, 2010
I'm starting with actionscript 2 and I can't figure out how I set a collision mask for enemies and characters. I've got birds that flap their wings but I only want the player to collide with the body, not with the wings, as they take up too much space and it would be unfair.
I tried mc.setMask and other things I found online, but somehow it didn't work, ie: did nothing. I think I don't get the way this works. I thought you'd need like an invisible rectangle that it checks collisions against instead of the actual animation.
View 11 Replies
Similar Posts:
Mar 16, 2010
I am having a problem with my collision game. When I try to make collision between 2 objects, this occurs: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Level$iinit().
Here is my PHP Code:
package {
import flash.display.*;
import flash.events.Event;
import flash.geom.Point;
import flash.events.Event;
import flash.events.MouseEvent;
public class Level1 extends MovieClip {
[Code] .....
My flash file is at [URL].
View 1 Replies
Nov 5, 2007
Like when the ball bounces off of other objects. I've tried "xvel *= 1;" but it does not work well at all and had some glitches.
View 3 Replies
Jul 4, 2010
currently i making this game and objects would spawn at random and be able to click but when de game starts itself, the spawn is correct but i am unable to make it stop when time goes to 0seconds.
View 1 Replies
May 20, 2010
in this how can rotate car when it goes to collied with the track side.
package
{
import flash.display.MovieClip;
import flash.events.Event;[code]............
View 1 Replies
Jul 28, 2010
I am trying to figure out the collision physics for a top-down racing game in Flash / AS3. I am currently using the hitTestPoint method for detecting collisions, but I don't know how to apply a decent physics method to bounce a vehicle off of a wall that it hits.
View 2 Replies
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
Nov 24, 2011
I'm trying to create a flash shooter game as my first project. But I can't remove the bullets and enemies when they are hit or off-screen.I've searched for a solution on the problem multiple times and copied about 4 of them (plus I've tried my own ideas) but they are not working.The current method of checking for collisions is:[code]How can I remove the enemies and bullets? removeChild and splice?
View 1 Replies
May 27, 2007
how can I make the collision detection working in my game?I find it really difficult because I have no idea where to start...What I want to do is, when the spaceship hit the asteroid, the game will over (jump to the "end" scene)
View 5 Replies
Dec 15, 2002
I'm having a problem with my multiple collision detection code for a platformer game.. It checks for collisions on all objects separately and it checks only one object per frame. I need to make somekind of a loop so that it would check every object in one frame. Anyone got an idea? It's coded like this:
[Code]...
View 4 Replies
Jan 16, 2012
I'm having a little problem with collision detection. I'm currently with very simple game, where the only thing that is off is the collision.I tried with hittestobject and (as I found) it checks for the outer layer (my objects are a circle, and a weird star), so this method was of no use to me. Then I tried with hittestpoint, and I found that it checks for the center of the objects, so game over happens only where the center of an enemy touch the center of my character.I know that I must have something missing and I found a lot of guides but all of them were with squares or with static objects
View 3 Replies
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
Nov 29, 2009
I m under the process to create a platform based game,but stuck in a problem ,its probably concern with x-axis, actually my player stops certain distance before right wall and with left wall too,i tried to reduce the distance but end up in failure,i have attached the concern fla.
[Code]...
View 5 Replies
Dec 27, 2010
[Code]...
I have a serious problem with Action Script. I'm about to code a new Jump&Run game with a simple gravitation Engine. And this is where I got my problem I can not solve! When moving the player through the levels, I want to move the layers instead of him. So the player stays somehow where he is but the enemies, ground, items ... move around - as in most of these games. The gravitation is intendet to affect every item/enemy (by ENTER_FRAME) and moves every object downwards until it hits the ground.
The problem is, objects of different Layers somehow don't get the right hitTest information. So when having two objects - the first on the same layer as the ground, moving both, everything is fine. But as soon as I put the object into a separate container like "itemsContainer:MovieClip" and I move that, the object doesn't get the right result for hitTestPoints. (Maybe it has something to do with localToGlobal??)
[Code]...
View 1 Replies
May 10, 2011
I am creating a scheduling application that shows projects (wrapped within a canvas) on a 2 week calendar timeline.If the user decides to move a project over by a day, i need to check and see if the moving project would then overlap with any other existing projects. If it does, one of the two projects would need to move down the screen along the y axis until the two projects no longer overlap.I've created a function that loops through a repeater item which is used to create the projects... the end result of this function is an arrayCollection that holds:
0. the id number within the repeater
1. the project title
2. x coordinate
3. y coordinate
4. the width of the project
5. the height of the project
I have also created a function that takes the two objects within the array collection and determines if they're overlapping.I can not, however, figure out a working loop that goes through the array collection, compares each item within it, checks to see if they overlap, moves the project if they do overlap, and then continues onto the next project.
Also, I need to make sure that moving one project will not make it overlap with another.I ended up having to reset each elements y value to 0 each time any project is moved and then re-evaluating whether or not they collide.
View 1 Replies
Dec 29, 2011
I have been trying to fix my collision handling for hours now, but it seems like I am running in circles. To be blunt, my collision handling sucks. It is easy to break, and hardly works on complex objects(like water in my case, see the test at megaswf . com / serve / 1577272)
For collision detection I am using the collision detection kit, or CDK.My level is made up of different large MCs, such as a "wall" MC containing all of the smaller walls, such as water, a tree, or a wall. CDK allows me to hittest the single walls by hittesting the large one, and not each one individually, making it easier for myself.My code has a lot of repetition(8 directional movement), so I will put a "//..." to simplify.
Main.as:
ActionScript Code:
public class Main extends MovieClip[code]......
I have literally been working on this all day, and only feel like I'm making it worse every time I change something. You don't have to spoon-feed me code, the idea should be enough...
View 0 Replies
Dec 3, 2009
I'm having a problem with a hitTest that I'm not sure how to correct. Long story short, I have a box that is added to the stage and beings to tween down to the bottom. If the user presses the left arrow to catch the object before it leaves the stage, they get 1 point (hooray!).The issue that I'm having is this...multiple instances of the same MC are supposed to be added to the stage by a timer but because of how I've set it up, they all have the same instance name. That leaves me with one of 2 options. I can get the hit test to work, but only 1 instance ever actually shows up or a bunch show up, but the hitTest fails. How can i add multiple instances of the same object, but still be able to determine if one of them is overlapping the box when the user hits the arrow key?[code]
View 3 Replies
Jun 13, 2010
I want to detect collision for several different objects, but want to keep the code as short as possible. whether I can use an array to hold the different movieclips and then detect collision with the entire array, or if I have to create a class and do it that way.
View 1 Replies
May 8, 2006
I'm making (or rather trying to make) a collision detection demonstration for my Media Studies coursework using a game as an example. However, I use FOR and duplicateMovieClip to create both a) the enemies and b) the bullets. how to register collisions with these objects.
Also, if anyone has any tips for using an array instead of the endlessly repeated "else if (x<num) {" lines, that'd be great to know!
For some reason I can't upload the ZIP file with the Flash in it on this Mac, but I'll upload it back on my own PC soonish. I'm not letting all this stuff I've typed out go to waste!
View 1 Replies
Sep 2, 2010
ok so I am making a game for a college course and I am having some difficulty getting the collision between my player and the walls to work. Here is my code
Code:
// Collision Wall Test
public function WallTest()
{[code]...........
I'm getting this error every time the function is called
"TypeError: Error #1010: A term is undefined and has no properties.at GamePlay_v01/WallTest()at GamePlay_v01/keyDownFunction()"
I've been at it for hours and cannot figure out for the life of my why its not working. I have set up sentry points around as a perimeter on my character.
View 6 Replies
Nov 27, 2011
I'm trying to create a sort of tree diagram such that, if you click on one of the circles, its child circles spread outward with some degree of randomness from the original circle, connected by lines. I have this working, but now what I want to do is make sure that none of the circles collide with each other and none of the lines criss cross. You can see the screenshot for what is currently happening. My code is below. How do I change this code so that it checks for collisions and avoids them? I've read up on flash's hitTestObject command, but that only works in the context one object to another. I want to test for one object contacting any display object.
import com.greensock.TweenMax;
var sw = stage.stageWidth;
var sh = stage.stageHeight;
[Code].....
View 2 Replies
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
Jan 16, 2011
I'm running a HitTestPoint to detect when two of my mc's collide, but I don't want them to be able to go right through each other. Someone suggested I find the x,y coords of the moving object when the collision occurs, then update that mc's coords to this x,y each time a collision occurs. I've been Googling but came up empty. Below is my code
private function __checkHit($evt:Event):void {
if (this.coin_mc.hitTestObject(target)) {
if (!hitting) {[code].....
View 2 Replies
Jan 4, 2011
I'm actually working on a multiple collision detection in actionscript 3.0, using pixel collision for a game for my assignment, where an enemy patrols around and searching for the hero. So, i draw a line between the enemy and the hero, to check whether there's some collision happened between those two. if the line colllides with an obstacle such as wall, door, etc. enemy will not be able to see the hero. When i tried a single line collision with a wall (one object only) it works perfectly.
But here's the problem. For the multiple objects collision (several walls and doors included), i added those objects in an arraylist, When i used for loop to check the collision between the line and those objects in the arraylist, none seems to react , except the first object in the arraylist or index 0.
Is there any simpler way to do the multiple collision detection?
View 2 Replies
Feb 7, 2010
has anyone found an AS3 source/Maths-lib etc that covers not just simple collision tests but swept collision tests (at least swept AABB/circle tests) for fast moving objects? I had a quick look at flixel but even that does not seem to have sweep tests for fast moving objects.
View 2 Replies
Jun 20, 2011
a way, to manage a multiple collision detection with pixel level detection, for objects, not necessarily circles, irregular objects.
View 5 Replies
Jun 7, 2010
I would like to drag and drop multiple objects and on collision activate/play a video clip.
View 3 Replies
Jun 20, 2009
is there a way to apply the mask to multiple objects in as3.0 ? one i try to do it using the .mask = it can only effect one object at a time ...
View 2 Replies
Feb 7, 2012
i want to mask objects with dynamic transparent PNG files in Flash Action Script 3.0
View 1 Replies
Jun 13, 2010
i've created a sprite to drag and drop around the stage. the sprite is masked and has it's mask as it's child so that it too will drag along with the sprite. everything works fine until i add a drop shadow filter to the sprite. when the drop shadow is added, i can only mousedown to drag and mouseup to drop the sprite if the mouse events occur within the original location of the sprite when it was added to the stage.
var thumbMask:Sprite = new Sprite();
thumbMask.graphics.beginFill(0, 1);
thumbMask.graphics.drawRoundRect(0, 0, 100, 75, 25, 25);
[Code]....
View 1 Replies