Stop A Rectangle From Going Past An Object After Collision Is Detected?
Oct 11, 2009
Assuming, for a rectangle that is controlled by the user using the arrow keys, that I do the following[code]...
Assuming that works in detecting the collision, what would I use to actually stop the rectangle from progressing through the wall?
View 1 Replies
Similar Posts:
Apr 3, 2012
The scenario: in Main, instances of class Bullet are spawned and added to the stage, and to the array bltarray, instances of class Enemy are spawned, added to the stage, and added to nmearray. This works fine.
The problem comes in seemingly sporadically, i.e. it works, then suddenly doesn't work soon after, when it doesn't work I get spammed with output errors and the score display is constantly rising, note it's the same instance of bullet and enemy. [code]...
View 1 Replies
Apr 3, 2004
I'm try to make the Collision Detected with hitTest for long time but it doesn't work. I have two objecct one is the Spaceship and rock. When those two hit each other. I want it to show text "Collision DetectedFrame1 script
var rockCount = 0;
var rockTimeGap = 1;
var nextRockTime = 0;
[code].....
View 3 Replies
May 20, 2011
how to respond when a rectangle hits another rectangle? I already know how to detect the collision, I just don't know how to respond to it. I'm just trying making a simple side-scrolling platform game where I have platforms I can walk on and bump against on all sides. I have searched everywhere and just can't find the tutorials I'm looking for.
View 6 Replies
Feb 8, 2012
I am building a tile based game, in which the player can digg away at all the tiles.The problem im having is that my collision detection code for the tiles only will detect a collision with the first tile placed, or any tile required i explicitly code its number in.
In all other examples, tutorials and code, this should work, and yet it does not on mine.heres the specific code , the array the cildren are stored in is called dirt, as they are dirt tiles.
ActionScript Code:
for (var m:int=dirt.length-1; m>=0; m--) {
forval.text=String(m);
if (dirt[m].hitTestObject(_player)) {
[code]....
this brings me onto another problem i am having, which is that now that the collision code is inside a for statement, the above code doesnt work correctly. normally the lastx and lasty should be recorded , and if there is a collsion, the player is shifted back to the last position there wasnt a collision.for some reason now, even though it should be looping faster and detecting the lasx and lasty even faster, it isnt, and although a collision is detected (only with child 0).
View 4 Replies
Apr 3, 2004
I'm try to make the Collision Detected with hitTest for long time but it doesn't work. I have two objecct one is the Spaceship and rock. When those two hit each other. I want it to show text "Collision Detected" This is my script
Frame1 script
var rockCount = 0;
var rockTimeGap = 1;
var nextRockTime = 0;
var startTime = getTimer();
[code]...
View 3 Replies
Feb 5, 2005
I want to create movement in a movieclip when an arrow key is pressed. I want the movieclip to start moving and not stop until a hitTest recognizes a collision with another object and then tells it to stop. I want the key to only have to be pressed once to start movement and not have to stayed pressed down. How would I do this?
View 2 Replies
Jan 10, 2011
I got it working for using the e.target of the mouse but now I need to filter through the array on enter frame and detect whether a collision is detected.[code]
View 4 Replies
Feb 22, 2010
As the title says: Stop object from moving further when collision occurs.
Right now I'm trying to make a sliding puzzle. So far I have a block which I can click and drag around, and a few walls which are the boundaries. What I'm trying to do is make an area where the block can slide within the boundaries. So when you try to drag the block into an direction it will stop, whether you got mouse_down or mouse_up. My script so far
Code:
stop();
//Sliding Blocks
MCBlock1.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
[Code]....
Also I need to use a lot of boundaries, so if there's a way to apply this script easily to several objects
View 1 Replies
Mar 22, 2009
most efficient way to test for a collision between a circle and a rectangle?
View 3 Replies
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
Jun 23, 2011
I've been trying to fiqure out how to use the collision detection on one side of a rectangle differently then the other sides. for example: Mario mashes boxes with his head, by standing under the box and jumping up. (I'm refering to just the Super Mario Bros. game). If Mario hits the box from the sides or top nothing will break or come out of the box. How do you do that in Actionscript 3.0.
[Code]....
View 2 Replies
Aug 19, 2011
I'm trying to make a labyrinth type game where you control a narrow spinning rectangle. And you have to navigate it through a course without touching the walls.
I've been looking for 2 evenings now and I just can't find any type of collision detection that will do this. I'm quite a novice so I'm beginning to wonder if this is even possible for me to accomplish. All the tutorials I find are assuming the player will be a square, circle or a point.
View 5 Replies
Apr 4, 2010
If I removeChild an object from the stage can it still be detected by a hittest? I have objects that are tweening off the stage and if they hit other objects they stop their tween i use removeChild to remove objects that I don't want a hittest to occur on which is the nature of my question.
View 1 Replies
Aug 11, 2011
I have another (newbie) question about FLARToolKit.This is Lee Brimelow's code to make 3 boxes on top of the marker.
package {
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
[Code]...
the flaw of this code is, after the marker detected, yes, the 3D object got rendered. but after the marker were not detected, the object still appeared on the screen (even though it did not move)
View 1 Replies
Sep 22, 2009
When i zoom into the page then move around the edge of the page can be moved past the edge of the browser window showing the static page which appears at the start of the document. Is it possible to use actionscript to stop the page being dragged past a certain point so the static page is not seen? On the example below the static page is white so it does not pose too much of a problem however im using the static page as a sort of instruction page and it looks a bit rubbish if the user drags a page past the edge of the view window and see's the original page. Example below. [URL]
View 1 Replies
Mar 29, 2010
I am TRYING to get an mc to stop moving when it contacts another mc using hitTestObject and a stopDrag command The probem comes is that I want to be able to drag the mc again, but because it stop dragging while it is in contact with the target I can't move it again.Can anyone tell me how I can stop an mc dragging without losing the ablility to drag it again
function hitMe(event:Event){ if (top_mc.hitTestObject(phone_mc) || foot_mc.hitTestObject(phone_mc) || body_mc.hitTestObject(phone_mc)){ reply_txt.text = "CONTACT"; removeEventListener(Event.ENTER_FRAME,hitMe); body_mc.x --;body_mc.y --;
[code].....
View 2 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
Aug 7, 2008
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.
View 2 Replies
Mar 16, 2011
I have an object who's movement I want to limit to a small rectangle on the stage.
View 6 Replies
Oct 7, 2011
I am currently making a game based on slicing other objects, basiclly when you hold down and drag your mouse and then release it an object that shows the cut will be created.
//Sliceline.as
package
{
import flash.display.Bitmap;
[code]....
View 1 Replies
Mar 30, 2010
I am currently creating a game in which the character is stationary in the middle and the world moves in relation to the character. When the character is not moving and not touching anything, I need the world to shift upward to meet the character and stop on collision detection. The problem is I have no idea how to conceptually make this work.
making assets "fall up" and stop when colliding with an object (basically reverse gravity).
View 2 Replies
Jul 15, 2009
I currently have some Flash code that adds a rectangle movie clip from my Library ("MaskRectangle") to use as a mask:
private function makeMask(w:Number,h:Number,posX:Number, posY:Number):void {
var msk:MaskRectangle = new MaskRectangle();
container.addChild(msk);
msk.x=posX;
[Code]....
View 5 Replies
Jan 2, 2010
I have three objects in the main scene (so far), one of them is draggable (up and down only), then the animated one that moves downwards and the start button (activates the animation). So I've been trying to figure out how to script the collision detection for the first two? The collision should take place not because I dragged the slider onto the animated block, but because the falling piece hits the slider after I pressed the start button.
View 4 Replies
Feb 7, 2009
I need to detect collision between my bezier curve (drawn using curveTo method) and a object, the curve is dyanamic and hence the equation changes every frame. I am looking for a efficient method to detect collision between curve and the object.
View 1 Replies
May 10, 2010
I have two MC's on the stage. One of them is standing still in one position, the second one is moving towards it. I want the moving mc stop right at the very centre of the first mc. I've tried using hitTestPoint, but I don't know how to set the proper parameters. If I put there just: mc1.hitTestPoint(mc2.width / 2, mc2.height / 2, true), the trace function I use doesn't seem to have even noticed the collision...
View 1 Replies
Jan 17, 2012
Is there a way to test collision with a child of an object?eg.
ActionScript Code:
obj1.hitTestObject(obj2.childObj1)
obj1 and obj2 are on the same level of hierarchy.
I am trying to test when an object collides with a particular location of another object so i made a 1x1 movieclip (childObj1) and placed it inside obj2 at that particular position.
View 3 Replies
Feb 19, 2008
I read the tutorial about Multiple Object Collision Detection. What I want to do is have there be 3 circles and 3 squares. the circles are moving randomly while the squares are stationary. The actionscript would need to be checking to see whenever the moving circles collide with the stationary squares. However, it doesn't seem to be working. I followed the logic of the tutorial pretty closely, by making a separate list for the instance names. Here is the code for the collision detection.
[Code]...
View 1 Replies
Nov 11, 2011
I want to create a function in which I can drag a MovieClip which will bump into other MovieClips on the stage without overlapping them. (i.e. the object cannot be dragged over or through other MovieClips).
function dragHolder01(event:Event):void{
if (mouseDownHolder01 == true) {
for(var m:int = 0;m<blockHolder.numChildren; m++){
[code].....
View 3 Replies
Mar 28, 2012
I'm trying to have an enemy's shell hit my player. I have the logic in place that detects a player's bomb hit an enemy, I tried to edit it slightly and apply the same logic to the enemies shell.
Code:
// check for collisionspublic function checkHits(event:Event)
{
[code]......
View 2 Replies