ActionScript 3.0 :: Stop An Object When It Hits Another?
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)
I am wanting to make a game, and I need a gravity code that works great. I want gravity, a jumpibg code, and then a code to make something stop when it hits another thing.
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.
am pretty new to Kirupa and Flash. I have a little problem, concerning a character hitting a wall. What i have: a char that can jump and move around by the arrow keys. What i need: character shall stop movement if he hits a geometry. But being able to start movement again, besides through the geometry. I'd like to reach this with gskinners CheckForCollision class. Have a look here: [URl] But i didnt manage my code to get it work. So maybe you could leak me some information on how to get this done. Heres my code so far:
[Code]...
edit admits: so far i have a character mc called "player" and one called "level". i would apply the code to the player, and it would be cool to have the possibility to check collision of the player with multiple MCs, not only the level.
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 ?
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.
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?
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()
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
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
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]
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.
I'm making a small adventure game, and I want the game to go to the next frame once the main guy MC hits another invisible mc, like where the door is. I suppose another way of doing this is when the main guy mc hits an xy coordinate. So basically what I want is a script that says, when MainguyMC hit another MC/ coordinate, go to frame 2
Is it possible to stop one object from moving into the space of another object?
I have 2 characters in a game, one is controlled by the user and the other just moves back and forth. at the moment the main character can pass right through the other character.
How can I make it so that the bounding box's never cross each other?
I have tried a hitTestObject, but this has to place the objects inside each other before the function is called. And if the main object is moving at high speed towards the 2nd object, then the 1st object will end up even further inside the 2nd object. Stop 1 object over / under lapping another?
I have this code where I want edge_btn to move to the left side of the stage, but I can't figure out how to get it to stop. It just keeps going. Also, I have edge_btn rotating the entire time in the beginning of the timeline.
I'm having a bit of a problem with this rotating object. It loops and never stops. I searched and found similar problems, but if I'm not mistaken most loops where done with tweens, unlike this one. Code: onClipEvent (enterFrame) { i = getProperty(this,_rotation); setProperty(this,_rotation,i + 7); } I basically want the planet to spin once, and then stop.
I'm trying to detect when an object (a golf ball) in my game stops bouncing. I need to track it's x and y position and tell when they both equal a set figure (the hole) a hitTest wasn't working as it was detecting each ball bounce not when it stopped rolling. So when the x and y both equal a figure.
if ((this._x = -106.5) && (this 47.55)){ _root.cheer.play(); }
I am making a new site, and was making buttons that looked a little similar like this buts on the left) and wanted that to do with Actionscript.I followed a tutorial on Kirupa on moving stuff with actionscript
I want it to remove everyone that it hits, but it only removes the first one that hits. I am sure the answer is simple, but i am slow. Here is the code:
ActionScript Code: function removeSpawn(){ for(j=0;j<lvl1A;j++){
I have 2 movie clips with a linkage. In a process both mc's are being attached lots of times and a new name is given to each every time.I want to make it so that is these 2 mc's hits each other they dissappear, but i can't do that because they all have different names and i don't know how to call to them.
Is there a way to keep track when an FLV hits a certain point in its playback WITHOUT using cue points? If so, how is this implemented and does it make the experience sluggish?
All I want to do is stop on a frame then click on an object and progress to another frame. MX was simple to perform this, with cs4 it seems to be a mine field any sugestions.
I want to rotate an object using the arrows on the keyboard when the mouse is over the object and it should not be possible to rotate the object when the mouse is not on the object. I know how to rotate the object, when the mouse is over the object, but when I put the mouse outside the object I can still rotate the object. How do I make the rotation stop?
If an AS3 method returns a reference to a complex type, is there any way to make that 'readonly', like how you can have const member functions in C++? An architecture I want to use calls for a class building itself from a passed template object... and really the template object should not be modifiable. I'm currently forced to add call-back enumerators and/or lots of extra accessor methods.