ActionScript 3.0 :: Game Loop - Detecting When Object Hits MovieClip
Jul 17, 2010
I'm trying to program this code:
public function enemiesDie(){
enemyLoop: for (var k:int = enemies.length -1;k>= 0; k--){
bulletLoop: for (var i:int = bullets.length -1; i>=0; i--){
if (enemies[k].hitTestObject(bullets[i])){
trace("hit");
[Code] ....
To detect when a bullet hits an enemy in a game I'm trying to make and I get this error:
TypeError: Error #1006: hitTestObject is not a function.
at Space_Hooligans/enemiesDie()
at Space_Hooligans/gameLoop()
View 2 Replies
Similar Posts:
Aug 15, 2011
I've got tree movieclips called: greenpip(this is the dragable object, which is visable), greenpip_target(which is invisible, but becames visible when greenpip hits it, and grrenpip is becaming invisible) and then the third one: greenpip_flask (which is the animation I want to play when the greenpip hits the greenpip_target).
Everything works but I don't know how to make the greenpip_flask play, when grrenpip hits the greenpip_target. This scenario takes place three times with three sets of objects
View 5 Replies
Apr 22, 2011
I am creating a tower defense game and I want to make a tower that shoots a bullet and every enemy that the bullet hits is damaged. The bullet can hurt multiple units. My problem is detecting if the bullet hits the enemies. Right now, I have the enemies in an array. With other towers, when an enemy is in range, the tower fires and when it hits its original target, it causes damage to that target.
For the tower I want to make, it will shoot the bullet the maximum range every time and I need it to damage every unit it hits on the way to that final destination.
View 4 Replies
Apr 12, 2011
I'm trying to figure out when a child is added to a movieclip "x", and handling/detouring this operation from withing this "x" movieclip.
I tried overriding addChild and addChildAt at with no prevail. The movieclips that are placed on the stage via flash still don't trigger addChild or addChildAt. However, tracing this.numChildren shows '2' correctly.
View 2 Replies
Jul 7, 2011
I have a game where the character walks around the screen and stops if she hits a wall or a hole etc... - typical. HOWEVER - I coudn't get her to stop walking. Is there any standard code for this. If you tell to stop walking then she can't walk back out either etc... Also, she walked into the hole a little so being in the hole she definately couldn't walk any more not even back out as she would be walking inside the prohibited zone.
View 3 Replies
Dec 19, 2010
I wonder if there is a way in actionscript 2 that makes something happen if an object hit another object with a specific speed. For exemple: If Object 1 hits Object 2 with a speed greater than 10 I want something to happen.
View 5 Replies
Dec 5, 2010
I have two movieclips A and B when the movieclip A hits the movieclip B , I want the movieclip A to be removed what code should i write for this flash problem ?
View 1 Replies
Nov 12, 2009
Im making a sort of maze game and have a ball that moves up, down, left and right when the corresponding arrow key is pressed. What I want to do now is introduce some walls, how do I make the ball stop moving when it touches a wall? (so it doesnt pass through the wall)
View 1 Replies
Jul 23, 2011
I have a grid of objects that have been added to the stage dynamically, the objects are either of a Class Red or Class Blue, how do I perform a hit test on the Classes? I want the Blue object to disappear once it hits a Red one.
View 3 Replies
Jul 30, 2008
I am creating a kids game in AS 1 and want a "good" sound to play when a "good" object falls into the beavers basket and a "bad" sound to play when it falls into the basket. What is the best way to handle this in AS 1?
View 3 Replies
Sep 14, 2010
Ok. So heres what I am trying to do. I want one movie clip to follow another one that I move around with actions on the main timeline.The problem is that the follower clip is linked to a class file and I cannot find a way to find the players position.
[Code]...
View 8 Replies
Jul 6, 2003
I'm trying to write an if then statement that will loop back to frame 1 once the next frame it hits is higher than 5. For some reason it doesn't work and I could easily go to frame six and add a go to and play but, I'd like to learn what's wrong instead of doing it the easy way.
[Code]...
View 14 Replies
Mar 23, 2011
I have a brick class where I have created a rectangle using flash.display.graphics.I am using this brick class to create a grid of 10 X 10 in another class called grid using new brick() in a for loop.I have another class called ball where I have created a circle with flash.display.graphics.The problem is that I want to remove / destroy individual bricks when the ball hits the bricks on Event.ENTER_FRAME which is not happening.the error I get is shown only for the last brick that is created in a for loop.ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at grid/ball_movement()// my function in enter frame event
The code I wrote in ENTER_FRAME is
[code].....
View 3 Replies
Mar 24, 2011
I have a brick class where I have created a rectangle using flash.display.graphics.I am using this brick class to create a grid of 10 X 10 in another class called grid using new brick() in a for loop.I have another class called ball where I have created a circle with flash.display.graphics.The problem is that I want to remove / destroy individual bricks when the ball hits the bricks on Event.ENTER_FRAME which is not happening.the error I get is shown only for the last brick that is created in a for loop.[code]
View 1 Replies
Oct 2, 2009
i have 2 intersecting movieclips.
is there a way to hit test point NOT detecting a bottom movieclip if the mouse is over the top movieclip?
View 3 Replies
Aug 19, 2009
I am using AS2 with Flash 8 Professional So, my problem is that I currently have a man in the middle of the screen, who shoots a line towards the mouse when I click. However, when I use hitTest to see if the line collides with another object, Flash recognizes the line as a large box if it is diagonal, so the hitTest isn't very accurate. The line only satys there for one frame, so I can't have the usual moving-bullet-style. I am either looking for a way to create an imaginary line with AS from the starting point to the mouse and beyond, and tell whether or not this line intersects with an object... or some other way that I haven't thought of to fix my problem. Keep in mind that the line rotates from a center point towards anywhere around it for 360 degrees.
View 1 Replies
Sep 26, 2010
Heres what I am doing:
I have a movie clip and when I click on it, it creates another movie clip. Great.
Lets call these mc1 and mcCreate.
The problem is that I want the mcCreate to stay until I have clicked something else than mc1.
I know I can use mouse out events but is there a way to detect that the object has lost the mouses focus?
View 4 Replies
Nov 26, 2004
I've used this code to detect a hit between a specific object and a certain MC
Code:
if(this.hitTest(_root.ufo)){
Now I want to know if its possible to detect collisions with everything except (ignore) certain MCs because I only have 3 MCS I don't want it to care about, but there will be about 200 or more I want it to care for.
View 1 Replies
Apr 5, 2009
I have an Object that has several parameters. In this case they are Arrays. For example: myObject.Name, myObject.Description (myObject.Name is an Array that contains a bunch of names)How do you detect all the parameters that are attached to the object without having to use the debugger for each instance?
View 3 Replies
Sep 13, 2011
I'm working on something where when a user places their mouse over a horse in a race, it will display the horse's name and post position. This works great and has a Mouse_OUT which then removes the display of the name/post position. However, I've noticed that if I place my mouse over a horse and leave it there and said horse moves away from underneath where my mouse was, the name/post position become stuck on the screen until you mouse over that horse again.
Actionscript Code:
horse1.addEventListener(MouseEvent.MOUSE_OVER, showPost1, false, 0, true);horse1.addEventListener(MouseEvent.MOUSE_OUT, hidePost1, false, 0, true);function
[code].....
View 2 Replies
Nov 2, 2009
I am trying to create a system for a Tower Defense that detects if an tower or some structure can be placed on the grid.
The conditions are that the grid must be free of any structures and within the area that allows structures to be built (not on enemy path). I've seen many games do this already, so there's probably something out there. I just can't find it, although I understand the logic.
View 2 Replies
Sep 30, 2009
I am having trouble finding the right keywords to find a solution to my problem. I want to make my app size dynamic according the size of the <object> tag set in HTML. Im searching for the code like: stage.width but showing me the fixed html attribute instead.
View 9 Replies
Jan 20, 2012
The task seems easy: I am loading a video via a netsream object (could be FLV or an h264 mp4) and I would need to check if this video has audio available (otherwhise sound control objects should be disabled or become hidden).
View 3 Replies
Apr 29, 2011
Okay, in as3 when you click, the object on the highest layer will be clicked on. I want someone to press the space bar and have the objects on the screen to check to see if it is touching a point.So I first tried hittest...
if (this.hitTest(myPoint)){
play();
}
Now the problem was objects behind other ones were thinking they were being "clicked" on.
View 4 Replies
Aug 28, 2007
I am trying to have a local shared object in flash to detect whether a user is a new user or a returning user. If they are a new user I want to do newUser function and if they are a previous user I want to do a previousUser function. This should all be happening on an onEnterFrame.
Here is my code I have so far:
//shared object - cookie
newUser_test = SharedObject.getLocal("newUser");
newUser.text = newUser_test.data.title = "new user";
newUser.text.onEnterFrame = function () {
newUser.text = "new user";
} newUser.text.onEnterFrame = function(){
newUser.text = newUser_test.data.title = "previous user";
newUser_test.flush();
}
View 3 Replies
Mar 7, 2010
I have a problem where I can't detect the end of a movieclip in my project.
I have the FLV video linked for actionscript, so that I can control it dynamically with a few other things using AS3.
[Code].....
View 1 Replies
Feb 21, 2007
I guess my question is pretty simple for some of the guru's here, but i gave up with this already Im writing an photo gallery application for a website, everything works just perfect, but i have the following problem: Im using the events onLoadComplete and onLoadStart to display an small popup alerting the user while the picture is downloading... so how could i check if the picture is already cached ?, so i could use an IF statment to only show the popup if the picture has not been downloaded before? This is the relevant part of the code that im using right now, it works perfect, but it shows the "loading clip" EVEN if the picture is already there
[Code]....
View 5 Replies
May 6, 2010
I'm trying to load different images from xml to movieclips by detecting the movieclips name dynamically via xml.Pratically i have 2 movieclips named "sera" and "diurno".I take the names and the relative urls via xml then i try to add the images to the moviclip that have the same name as the xml, so i know that the "sera" movieclip have the "sera" image.
Code:
var loader:Loader;
var nomeMovieClip:String;[code].....
View 1 Replies
May 31, 2004
i have one movieclip and i have another movieclip>enemy...okay so when the first movieclip goes over the enemy, nothing happens until i roll out! all i want to do is the movieclip, when it hits the enemy, it goes to the enemy's second frame and that's it ! there are no syntax error in this script, just something i want to do that apparently doesn't work right.here is my code:
Code:
onClipEvent (load) {
speed = 2;[code]...
View 14 Replies
Aug 10, 2010
I'm making a custom slider component. The head (the thing that you drag) is programmed like this:
head.addEventListener(MouseEvent.MOUSE_DOWN, function():void {
head.startDrag(false, new Rectangle(stubDiv,0,width - stubDiv - ((levels-maxLevel)*stubDiv),0));
[code]......
View 2 Replies