Help With Collision
I have to Movie clips both with instance names of ball and paddle. How do i get the ball to reverce direction when it comes into contact with the paddle? I have tried using a speed variable and adding or subtracting numbers from the variable to reverce direction but i can't get the actionscript right. Please help.
FlashKit > Flash Help > Flash MX
Posted on: 10-27-2002, 04:54 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Collision?
hey anybody know how to make a collision between two object? if you do, please let me know, this is quite urgent!
Collision?
I've been reading about tests for collisions, there seem to be a lot of people concerned about collisions, what is that? What does it mean? Is it a good or a bad thing?
Collision
Ok here is the deal..i am new to action scripting so i might be making a silly mistake..i have a button and a vertical bar on stage..the vertical bar keeps on moving from one end of the stage to another..i have the drag function associated with the button..i want to drag the button and place it in the middle of the stage so that whenever the bar passes over it, it triggers a sound here is the code for that
on (press) {
startDrag (this);
}
on (release) {
stopDrag ();
if (this._droptarget == "/kit") {
_root.kit.gotoAndStop(20);
}
}
now this works and i can hear the sound but not the way i want it to...i have to drop the button exactly as the bar passes (i think)..so it does not trigger off the sound as it passes the second time or subsequent times.. Can anyone tell me if i have to use something else for that purpose..like Onclipevent or something..so that it triggers off a sound everytime the bar touches the button..thanks for your help!!!
Collision
Hi list
A thing to think about because I don't get out of it. Hope somenone can help me
I created a tool where the user can drag squares. By dragging a new square I use the duplicate movie and give the name "square" add n1. n1 stands for the number of squares I have drawn.
Now my problem is that when the user draws a squares it cannot be drawn on the place where a square is already drawn. He also as the ability to drag the square all over the place but not over an existing square.
So eventually he can draw as many squares as he wants but not at a place where a previous one is drawn and when he drags it must not intersect with one of the squares already drawn.
I think I need to use a list or something. So when the first square is drawn nothing is put in the list (nothing to intersect with) When the next square is drawn the previous squarename ("square1") has to be put into the list. When the third one is drawn, "square2" has to be added to the list and so on.
So when I drag a new square I check for hittest with one in the list
When I move (drag) a square that has already be drawn I must remove the name from the list or something to check if it not collides or intersects with one of the list
As you can see I can follow the logic but I'm not able to put this in code. I'm a ingo user and I am not that familiar with actionscript.
Hope someone can help
thx
Tom
Collision
Hi list
A thing to think about because I don't get out of it. Hope somenone can help me
I created a tool where the user can drag squares. By dragging a new square I use the duplicate movie and give the name "square" add n1. n1 stands for the number of squares I have drawn.
Now my problem is that when the user draws a squares it cannot be drawn on the place where a square is already drawn. He also as the ability to drag the square all over the place but not over an existing square.
So eventually he can draw as many squares as he wants but not at a place where a previous one is drawn and when he drags it must not intersect with one of the squares already drawn.
I think I need to use a list or something. So when the first square is drawn nothing is put in the list (nothing to intersect with) When the next square is drawn the previous squarename ("square1") has to be put into the list. When the third one is drawn, "square2" has to be added to the list and so on.
So when I drag a new square I check for hittest with one in the list
When I move (drag) a square that has already be drawn I must remove the name from the list or something to check if it not collides or intersects with one of the list
As you can see I can follow the logic but I'm not able to put this in code. I'm a ingo user and I am not that familiar with actionscript.
Hope someone can help
thx
Tom
Collision
Heelo
I'm stuck it's simple and hope someone can help me out quickly...
I have 2 movie clips, one is controlled with the up, down, right, left buttons (like a game) control (I used a component from flashcomponents.net to do this btw). The other is static.. anyway I want to detect when the controlled movie clip hits the static one, I know the if statement would be used but I don't anything else I'm afraid.. sample code would be excellent
Thanks in advance
Bob
Collision?
I have a movie clip that is controlled by the arrow keys. When the movie clip gets to another movie clip, I want it to go to the next scene. I know this has to be fairly simple...
Anyone know how I could do this?
Collision
ive got a movieclip that the user can move around with the arrow keys. i want it so that they cant just move it thru a wall. but so it stops when it hits the wall.
[Edited by harness on 09-06-2002 at 02:39 AM]
Collision
basically it's a labyrinth-game, view from above. when the players bump into any rock, tree, shore or wall, i want them to freeze and maybe turn black and white for a second or two before they may move on.
how is this done...?
/bensa
Hit Collision
hi. can sum one help me out please. i have a main scene, with in that main scene i wud like the user to be able to drag a video and when the release it on top ov the vid player i want the specified swf file to open. can sum 1 please help me out with the coding.
in simple terms, i want an swf file to open when a movie clip is moved over another.
please help me if you can.
thanks Chris
Collision
How can i make a movieclip bounce off another one?
I have 2 balls which i want to bounce off eachother when they meet. Is that possible or is that advanced?
Collision
hi,
i need a simple script like this:
one movieclip is controlled by user [this ill do by myself]
ond there are other movie clips, that fly around [this ill do by myself] and :
When they collide with users movie clip, the scripts takes the user to the other scene.
Collision Help
what is the action script you put in a mc that is moveable by the arrow keys to keep it from going outside a boundry line (which is larger than the stage) I just want it to stop right at the boundry line and not be able to move any farther.
Collision
When the car that i have drives at top, speed, it can pass right through the boundries.
Heres the code i have for it.
code:
onClipEvent(load)
{
speed =0 ;
}
onClipEvent (enterFrame) {
// make the car go forward
if (Key.isDown(Key.UP)) {
speed += 1;
}
if (Key.isDown(Key.DOWN)) {
speed -= 1;
}
if (Math.abs(speed)>20) {
speed *= .7;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 15;
}
}
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
How can i fix this?
Collision
I have already tried looking in the movies, and tutorials and I still can't find what I am looking for.
I have a flash movie where you press one arrow key the circle goes that direction, you know, like an rpg interface. but my circle can walk out of the flash movie and you can't see it! How do I make border around the movie to where the circle can't get out!?
Collision...
hey ppl.
im creating a simple game where the character moves around according to keys pressed. then there's a random movie clip falling from the sky, the user has to get the character to 'catch' this movie clip by running over it. how do i make this random movie clip dissapear as if taken by the character as soon as it collides with the character mc?
any ideas?????
Can Some 1 Help Me Wit Collision Plz
im trin to mak a game and i want the character to go up and down stairs but the character keep fallin through when u go up the stairs. i v attacted a file 2 show u what im talkin bout..
Hit / Collision
I am trying to make a movieclip respond to a mouse position matching its own, by playing another frame, named "snap"
its as close as i can get below.....
Code:
if(_mouse.hitTest(_root.mov_mc))
_root.mov_mc.movbits_mc.gotoAndPlay("snap");
it would be good also to make the response occur with the mouse on an area a bit bigger than the m.clip... should i add a seethrough component or might there be a method of scripting a bigger hit area??
Could someone point me in the right direction please...?!
very many thanks in advance for any help.
C
Collision
Here is a simple question that is always overlooked!!!!
I have two movie clips. One is my game player an the other is an enemy.
What code do I use to detect collison between the MClips and trigger a gameover frame or something? pls help!
Collision - Plz Help
Hi
I have 2 symbols. I need 1 of them to detect a collision between the 2 of them.
I added a layer called "actions" to 1 od the symbols and put in the following code
Code:
var hit:Boolean = false;
hit = this.hitTestObject(human_hand);
if (hit==true){
human_hand.gotoAndStop(2);
}
However I get this error:
1120: Access of undefined property human_hand.
I am assuming this is because the code is within the object and human hand is on the main stage.
How would I fix this?
Thank you
Mc In Mc Collision
I cannot make this simple collision work, when i have the mc hit test it works, but when i want an mc inside of the mc to collide it does nothing
this is on another layer on the scene.
_root.sword.onEnterFrame = function() {
if(this.hitTest(_root.enemy)) {
enemy.gotoAndStop(5);
}}
if i change sword to man which is the mc on the scene that has multiple mcs on it one of them being the sword
but when changed to sword it does not recognize the sword MC that is on the man.
Appear On Collision
How do i make a wall appear after a ball collides with it?
The instance name for the ball is ball. How could i put the code on the wall (that would be preffered)?
I have been trying to write the code myself but to no avail.
anyhelp is appreciated.
Collision Help
I have coded some collisions before, as in when a character touches another object he dies.
Im trying to make a game where the main character is pushed back by other objects. Does anyone know how i can do this?
Collision Help
Hey
ive got myself 2 circles, that are bouncing, moving & rolling and reacting to gravity... but im having such a hard time trying to make them collide-able... right now they're just rolling/bouncing pass into each other..
could anyone try to help ? i'll post the fla if needed...
Help With Collision~~~
Can somebody please help me make it so that when i move the bomb into the block the bomb goes back to its original place.
The code moving the bomb is:
var speed:Number = 2.3;
ball_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x = this._x + speed;
} else if (Key.isDown(Key.LEFT)) {
this._x = this._x - speed;
}
if (Key.isDown(Key.UP)) {
this._y = this._y - speed;
} else if (Key.isDown(Key.DOWN)) {
this._y = this._y + speed;
}
};
I want to make it so when it collides with a movie clip called "block_mc" it goes back to its original position.
The block is supposed to be in the content layer not the action layer btw, Please help =}
Collision
Hi all
I am doing some code to simulate collision, but I found that my stage bounds not accurate, and when doing resizing for it more strange behavior happened, Like doing collision with nothing
here is my code
//Calculating a random direction for the ball
var angle:Number;
do{angle=Math.floor(Math.random()*100);}
while(angle>=85&&angle<=95);
angle=angle*Math.PI/180;//claculating angle in radians
//////////////////////////////////////////////
stage.addEventListener(Event.ENTER_FRAME,MoveBall) ;
/////////////////////////////////////////////
var i:int;
var j:int;
if(Math.random()<0.5){i=-1;}
else{i=1;}
j=i;
////////////////////////////////////////////////
function MoveBall(e:Event)
{
CollisionDetectionWithWalls();
ball.x+=(i*1);
ball.y+=j*Math.tan(angle);
}
function CollisionDetectionWithWalls()
{
//stage.invalidate();
if(ball.x>=stage.stageWidth || ball.x<=0) {i=-i;trace("X");}
if(ball.y>=stage.stageHeight || ball.y<=0){j=-j;trace("Y");}
}
MC Collision
Hi
I have some number of MC on Stage, guess 20 and those MC move from left to right. While moving, its possible that any of these 20 MC can collide with a movie call mov8. But I am not able to get the detection. I guess I am not targeting the 20 MC right. Here is the code.
ActionScript Code:
var allFood:Array = new Array();
var MyTimer:Timer = new Timer(350,154);
MyTimer.addEventListener(TimerEvent.TIMER,foodFunc);
MyTimer.start();
for (f=0; f<20; f++) {
var fd = "food"+f;
allFood.push(fd);
trace(allFood[f])
function foodFunc(event:Event):void {
if (allFood[f].hitTestObject(myCell.mov8)) {
trace("Collision")
}
Thank you
Collision Help
ok so basically i need to create a project in flash where a ball which is controlled by the user eg. press "w" to go up. I need this ball to collide with my logo what actionscript can i use to comple this task??? thanks!
Collision
Im makeing a driving game and i have a rock thats a mc and a car thats a mc, what i need to do is when the car goes over the rock the car shakes, i have no idea on collion as. is there ne one that can help? thanks
Collision
Hi..
I'm working with a game, and I need some help...
In the game is the player a "car", and when it drives over a symbol, the movie gonna jump to another frame...!
How can i do this?
I've do so the car is driving (the arrow-buttons).
Please help!
Collision?
Hi,
I am trying to make a field where you can see circles (This is what I have now) http://www.studiojfd.com/flash/
But I want always see the B (in the middle) and no overlapping from the circles. I don't know how I can do this... Please help me....
(sorry for my bad English)
Collision Help - Please?
Okay so I'm attempting to make a code that executes something when the cursor collides with a Movieclip called player. I'm having quite some trouble with the syntax, however. No matter how I try to fix the code, there's always a syntax error involving a missing parenthesis.
Code:
Mouse.hide();
addEventListener(Event.ENTER_FRAME, moveCursor);
function moveCursor(event:Event):void{
cursor.x = mouseX;
cursor.y = mouseY;
if(cursor.x >= player.x-player.x/2 and cursor.x <= player.x+player.x/2){
if(cursor.y >= player.y-player.y/2 and cursor.y >= player.y+player.y/2){
trace("hit");
}
Collision
Im makeing a driving game and i have a rock thats a mc and a car thats a mc, what i need to do is when the car goes over the rock the car shakes, i have no idea on collion as. is there ne one that can help? thanks
Collision
I am creating a game where the ball can bounce off of objects. I understand the basics of hitTest, but obviously not enough to get the ball to recognize a wall and react to it. Can anyone help me? I am wanting the ball to bounce off of the walls. Either I am not seeing something, or just haven't found it yet. Your help would be much appreciated.
Collision
Hi..
I'm working with a game, and I need some help...
In the game is the player a "car", and when it drives over a symbol, the movie gonna jump to another frame...!
How can i do this?
I've do so the car is driving (the arrow-buttons).
Please help!
Collision
i know hittest can test collision but i don't know how
would it be better just to write my own collision?
Help On Collision
I made a game useing the simple platform game, i wana no how to amke a collision, i want an enemy walking on it sowhen you jump on it it blows up, but if it walks into you, you die, any help
Collision Detection
I have many instances of a movie clip (by using duplicateMovieClip) on my stage, each with a name of "clip1", "clip2", "clip3" etc.
I have many instances of another movie clip, like the one above, but all derived from a different original movie clip. They're named "something1", "something2" etc.
I want to put an "if" statement that performs a "hitTest" between one of the "something" movie clip instances and ANY of the "clip" instances.
This is the code I have inside the onClipEvent (enterFrame) of the "something" instance:
onClipEvent (enterFrame) {
if (this, hitTest(_root.varClip)) {
this.removeMovieClip();
}
}
and I have this code in a frame on the _root level
for (var i = 1; i<=3; i++) {
_root.varClip = ["clip"+i];
}
Nothing is working this way. Is there some other way that I can check the collision using arrays?
Am I mixing up the paths?
I'd really appreciat some help with this. I feel like I'm so close already.
Thanks
Kevin
Collision Detection
Alright troops?
I wonder if any kind (and talented) souls could give me a hand? I'm trying to build a pac-man type maze game and I'm not sure about how to produce collision detection to stop my character goin' through the walls. I'm really not sure where best to begin on this one, so any advice at all is greatly appreciated.
Cheers
Ok Ok.. How Do You Do Collision/hit Test?
I'm not sure, and my msn messenger isnt working for someone to help me on there, and I need it. Ok heres what I got,
1 car, thats you, you drive with your keyboard.
a tree, that is the object, how can I make it so when the car hits the tree it makes it go to a different frame, if it helps. I made CAR, and TREE a movie clip. Should I have made tree a button? I'm not sure where else i could find info on hit test, except here, so help if you can.
thanks in advance.
Collision Detection On 5
I'm using the collision detection feature on Flash 5, which works nicely, but I don't know how to make a movie detect another instance of itself without detecting itself
To illustrate what I mean, I'm making a battle of Ants. Each ant is created by an Array, and I want their heads to detect the collision with another. So I'm using the following code within the 'head' movie:
flag = this.hitTest(_root.ant);
if (flag == true) { do something... }
What should I use instead of _root.ant?
Thanks!
Help Me With Collision Detect Please
Hello.
I want to be able to roughly duplicate this:
http://www.zanpo.com/index2.html
Like an old adventures of lolo type game.
I can make the dude move and keep him from going off the screen (pretty well - help here too if you want). I can't seem to figure out how to keep him from running into walls I make. How should I make the walls. Does everything have to be in a grid? Please help!
Collision Detection
Hi,
I am trying to make a game. I have a character and a 3d floorplan he walks around in. Instead of moving the guy, I move the floor so it looks like he is moving, but he stays in the center of the screen. So I got the hit test to work, but I have one big object that my character is colliding with (the map). I know that I can break apart the floor and have separate walls, but I was hoping there is a way to keep using only one object. The object is vector, so why can't flash only see the filled in areas? If anyone can help me with this, I would greatly appreciate it. Thanks.
Stan
Graphic Collision ?
Hi,
Im a bit of a newbie to Actionscript, do you know how i can get a collision to recognise the actual shape of the graphic, instead of the Blue box around it !!!!!!!!!
Help would be appreciated
Cheers
Collision Detection
hey guys
i'm trying to create a game where you're a tank and you move around using the mouse (you click where you want to move to and the tank drives in a straight direction towards the mouse)
I know how to make the tank move, the thing i need help on is the collision detection, the tank is a rectangle movie clip and the object i am colliding with is a rectangle too.
this is what i need to happen:
when the tank collides with the object, the tank will stop
there's a varable in the tank MC that if it is set to TRUE the tank will move, if FALSE the tank will stop where it is
the variablie is called 'GO'
i know the basic
if(this.hitTest(_root.object)){
this.go = false;
}
but if i do this, then the tank will still be touching the object, so when the tank touches the object, i would like the tank to be moved 5 pixels away from it so it wouldn't be touching the object
is there anyway i can do this?
Collision Detection
Ok, um i have this video clip that i can move around the screen using the arrow keys on the keyboard. I also have some other graphics on the stage. Now, what i want to do is when the movie clip touches one of these other graphics the movie clip stops and it cant go over the particualr graphic. so i now hae to move the mvie clip around the graphic. Can someone please help me on how to do this. Your help is greatly appreciated. Thank you in adavance for any help you can offer.
Kind Regards,
The Prophecy.
Partial Collision
how can i make it so a movieclip has a different collision or no collision through part of it? do i nest a separate movieclip within the parent clip; it only last part of the duration of the parent clip?
if so, how do i code so the nested clip registers on the collision?
Collision Problems
my actionscript for this game im making has problems the problem is that when the car hits the enemy it doesnt explode unless you stop during game play here is the code see if you can help me
onClipEvent (load) {
function reset () {
this._x = 600;
this._y = random(200)+100;
enemySpeed = random(4)+1;
this.gotoAndStop(1);
}
reset();
}
onClipEvent (enterFrame) {
if (_root.spaceship.scrollStart) {
this._x -= enemySpeed+_root.mainGround.groundSpeed;
} else {
this._x -= enemySpeed;
}
if (this._x<-10) {
reset();
}
if (this.hitTest(_root.spaceship)) {
_root["enemy"+i].gotoAndPlay(2);
}
}
How Do You Script A Collision?
I've been messin around w/ flash 4 for a while now, and i just downloaded the flash 5 trial...
so how DO you script a collision?
im kinda making a weird game where cars crash into each other and blow up....???
help!
|