How To Attach A Sound To The Ball Bouncing Off The Floor
I got this bounce.wav in my library.
I want to make the ball to have the bounce sound whenever it hit the floor of my this flash.
How do i go about doing it?
Pls help.
Many thanks.
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 06-27-2006, 05:25 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Can't Get The Ball Bouncing The Right Way
Hi. I'm trying to make this game where the ball bounces on leaning walls.The ball moves this way:
this._x+= speedx
this._y+= speedy
As long as the walls are vertical or orizontal I just put speedy=-speedy and speedx=-speedx and it works fine but how I am going to recalculate speedx or speedy (positive or negative numbers) when the ball hits a wall with a certain angle?
Thanks.
Bouncing Ball
I've created a 20 frame movie clip symbol of a ball moving up and then back down. I placed this MC in my main scene and made it move across the stage within a 50 frame time span. I was expecting the ball to move up and down as it moves across the stage but it does not.
What am I doing wrong?
Bouncing Ball
Came to this site for some help as my lecturer is no help at all. I'm trying to make a small animation of a ball bouncing up and down realistically. Apart from not knowing about the actionscript necessary to emulate gravity, I also can't figure out how to make the ball "squeeze" slightly when it gets to the bottom of it's bounce.
Any tips, help, anything really would be appreciated. Bear in mind that I'm completely new to flash
Ball Bouncing
Ok help is what i need
I want this circle to go all bouncy off the edges of the circle and stuff.
But it wont work
here is the fla and thanks in advanced
Bouncing Ball
Could someone point me to a tutorial or a file that has an object (that could be replaced) that bounces around a screen. I'd like to make a screen saver out of it.
Bouncing Ball Fla
Hi all,
I have been away from flash for almost two years and have been asked to do a project that I have done a thousand times but am drawing a blank. If someone could direct me to an fla that has balls randomly bouncing around the screen and nothing else I would greatly approeciate it. Thanks
Christopher
Bouncing Ball
Hi,
I have managed to make a ball that bounces from the walls and, basicaly, flat edges. The user controls the ball, when they release the movment keys it bounces arround for a while until it stops.
This is great, but how do I make a ball that bounces off any surface and looks realistic? Please could someone give me the code to do this.
Thanks!
Bouncing Ball
Hi,
I have managed to make a ball that bounces from the walls and, basicaly, flat edges. The user controls the ball, when they release the movment keys it bounces arround for a while until it stops.
This is great, but how do I make a ball that bounces off any surface and looks realistic? Please could someone give me the code to do this. I know the maths could get complicated, but I know it's possible - I've seen this done before.
Thanks!
Bouncing Ball
Hi,
I have managed to make a ball that bounces from the walls and, basicaly, flat edges. The user controls the ball, when they release the movment keys it bounces arround for a while until it stops.
This is great, but how do I make a ball that bounces off any surface and looks realistic? Please could someone give me the code to do this. I know the maths could get complicated, but I know it's possible - I've seen this done before.
Thanks!
[F8] Bouncing Ball Help
I want to make a ball that bounces, but each bounce is lower than the previous. I made a scene, created the floor movie clip and the ball movie clip, giving the ball the instance name ball. In the ball movieclip i put this code:
onClipEvent(enterFrame) = function() {
var ymov:Number = 0;
var gravity:Number = 1;
ymov += gravity;
ball._y += ymov;
if (this.hitTest(floor)) {
ymov *= -1;
}
}
but when I test for errors I get this:
Description Source
'{' expected onClipEvent(enterFrame) = function() {
What am I doing wrong?
Ball BouncIng
how do u make a ball bounce freely and realitiscally at all angles. And the speed(velocity) equals to to how much u drag the ball??i need this to create a basketball gaMe,..,right now i only managed to make the ball bounce up and down. If u know email me at spiderwick_1988@hotmail.com . Thank.Rachel=]
Bouncing Ball
I have a bow made of 4 MCs, one on each side. When the ball MC loads I want it to start traveling in a random direction. When it hits a wall of the box i want it to bounce off with an opposite angle. for example: if the ball was traveling at a right angle along the x axis toward the wall on the right, i want it to reverse its direction on the x axis. i can do this but the hard paart comes when i try to get it to bounce at an angle off the wall. So if the ball is traveling at a wall at a 45 degree angle it bounces off as if it would on a pool table(where the ball bounces at the opposite angle). Its hard to word this sorry. I hope you understand. So how would i script the ball to do this?
thanks
Bouncing Ball
hi,
anyone know how i would just make this continuosly bounce off the walls...
http://www.atreyuonline.com/flash/gravity.html
Click Here to download the .fla file!!!!
if someone could look at the code and point out what i need to change that would be awesome...thanks alot!
Bouncing Ball
100% sure it's been done before, but what the hell I'll post it anyway.
[swf="http://www.cannedlaughter.net/bounce.swf"]width=550 height=400[/swf]
http://cannedlaughter.net/bounce.fla
http://cannedlaughter.net/bounceMX.fla
//EDIT: doesn't work in FF
Bouncing Ball
hi,
anyone know how i would just make this continuosly bounce off the walls...
http://www.atreyuonline.com/flash/gravity.html
Click Here to download the .fla file!!!!
if someone could look at the code and point out what i need to change that would be awesome...thanks alot!
Bouncing Ball
100% sure it's been done before, but what the hell I'll post it anyway.
[swf="http://www.cannedlaughter.net/bounce.swf"]width=550 height=400[/swf]
http://cannedlaughter.net/bounce.fla
http://cannedlaughter.net/bounceMX.fla
//EDIT: doesn't work in FF
Ball Bouncing Off Of A Box
I have a movie clip (square) that moves from the top of the page to the bottom of the page, then another one (a ball) bouncing all over the place. I have it so when they hit, the ball bounces off depending on which part of the square it hits (top, bottom, left, right). The problem is, the way it picks which way to bounce (if it hits the top or bottom side it reverses it's y direction, left and right side chang x direction) doesn't seem to be working. The code is attached, and you can find the swf at www.madskater.com/randfiles/brokenswf.swf (just check the second checkbox on the initial frame, and set the speed to 5 or so to slow it down). It works probably 60-70% of the time, but for some reason when it should bounce off of the bottom, for example, it will act as if it had bounced off of the side. Help would be appreciated.
if (Math.abs(this._y-(_root["fallingblock"+k]._y))>Math.abs(this._x-(_root["fallingblock"+k]._x))) {
if (this._y>(_root["fallingblock"+k]._y) && yspeed<0) {
yspeed *= -1;
} else {
if (this._y<(_root["fallingblock"+k]._y) && yspeed>0) {
yspeed *= -1;
} else {
xspeed *= -1;
}
}
} else {
if (this._x>(_root["fallingblock"+k]._x) && xspeed<0) {
xspeed *= -1;
} else {
if (this._x<(_root["fallingblock"+k]._x) && xspeed>0) {
xspeed *= -1;
} else {
yspeed *= -1;
}
}
}
Ball Bouncing Within Another Ball
Hi,
I am trying to create a script so that a ball will be able to:
1) Start within a larger circle and move in a random direction and a random speed, and
2) Bounce off the inside walls of the larger circle.
I want to make it so that the ball will be able to bounce off the tangent of the larger circle at the point where they hit (so the bounce will be accurate), but I don't know where to begin...
I can make the ball start within the circle and start moving in a random direction and a random speed, but I've looked everywhere for any scripting reference to bouncing off tangents to a circle and I have found nothing for actionscript.
All help is greatly appreciated! Thx in advance!
Making A Bouncing Ball
I recently saw a movie tutorial for flash that showed how to make a ball looked like it was "bouncing." Something about speeding it up and then it slows down when it gets to the arc... i dunno. it looked like it was a VERY easy thing to do but for the life of me I can't find that movie again to figure out how (I didn't pay attention enough the first time). Could someone please help me figure out how to do this, thnx!
Rotating And Bouncing Ball
Hi,
I am desperately looking for a way to make an interactive (Soccer)ball that bounces AND rotates. There are lots of samples of bouncing balls, but none of them are rotating!..The idea is that you can drag the ball with your mousecursor and when you release the ball, it bounces and rotates until gravity makes it stop...Who can help me!
Thanx,
Bart
Bouncing Ball Tut Question
Hi,
I'm new to Flash 5 and I've been playing around with the tut on making a bouncing ball as found in the book Flash Games Studio (friends of Ed, so far, so excellent).
You can the swf output here:
http://www.inflash.com/bouncing_ball.html
According to my calculations, the shadow should just be touching the bottom part of the ball, but it is way below it.
I thought getting the y position of the ball and adding the ball's height would give the y position of the shadow, but apparently not.
What am I missing?
Here's the script located in the ball mc:
Code:
////Ball properties
onClipEvent(load)
{
circumfrence=Math.PI*_width;//find the circumfrence of the ball
}
onClipEvent(enterFrame)
{
_x+=8;//move the ball 8 pixels per frame
_rotation=_x*360/circumfrence;//rotate the ball
_y=-Math.abs(100*Math.sin(_x/75));//create bounce
if (_x>=575) {_x=-54;}//if off screen right, restart left
}
and the script in the shadow mc:
Code:
////Shadow properties
onClipEvent (load)
{
ball=_parent.ball;//set ball to equal the ball mc
_root.ball_height=ball._height;//set the text field ball_height to hold the value of the ball's height
_root.start_y=ball._y;//set the text field start_y to hold the value of the ball's starting y position
_y=(ball._y)+(ball._height);//set the y position of the shadow to be the y position of the ball plus the height of the ball
_root.mod_y=_y;//set the shadow's y position to the text field on the main stage
_root.line._y=_y;//set the line mc to the y value of the shadow
}
onClipEvent (enterFrame) {
_x=ball._x;//set the shadow to the x value of the ball
_xscale=_yscale=-(.5*ball._y)+50;//resize the shadow to match the distance of the ball from the shadow
_alpha=100+(.5*ball._y);//set the alpha to match ball distance from shadow.
}
Bouncing Karaoke Ball
hiya
anyone know where i can get my filthy mitts on a script which is like that ball that bounces around on the text in the karaoke screens. Its a mouse-follow bouncing thang. Also seen on some old hanna barbera cartoons...know what I mean? The little white ball bounces on the words you're supposed to be singing.
Any help would be greatly appreciated,
cheers,peace,the whole fandango...
jan peiro
Ball Bouncing Problem
Ok i want 2 balls to bounce off of the wall here is my code
..........................................
main
frame1
...........................................
duplicateMovieClip ("ball", ball+i, i);
i+=1;
if (i>20)
gotoAndStop(2);
stop;
................................................
frame 2
..............................................
stop;
................................................
movie clip ball
frame 1
.............................................
_x = Math.random() * 740;
_y = Math.random() * 480;
myVarY = Math.random()*10-5;
myVarX = Math.random()*10-5;
................................................
frame 2
nothing
.................................................
frame 3
.................................................
_x += myVarX;
if (_x>730) _x = myVarX*= -1;
if (_x<10) _x = myVarX*= -1;
_y += myVarY;
if (_y>470) _y = myVarY*= -1;
if (_y<10) _y = myVarY*= -1;
gotoAndPlay(2);
The mc ball duplicates but it starts doing this crazy jiggle once it hits the walls.. like its stuck.
I have flash 5.
Thanx for your time.
Bouncing Ball Effect Plus....
I didnt know how to title this post so I guess the simplest thing to do is to explain what I'm trying to do:
I got the ball to bounce up and down today...unfortunately, I can't stop the ball from continuously bouncing...I had wanted it to
a) stop/pause bouncing at some point (preferably on its upward flight state)
b) and upon stopping...do a spin several times...
c) after the spinning motion...bounce down and stop
c.1 it would be great if the ball could spin down...and stop...
Well, that's the animation i'm trying to do...somebody told me about doing a count variable & conditional loop to a certain number of times... But how do I do this??
Appreciate any tips on this.....uhmm, please be specific as possible
Thanks!
Bouncing Ball + Boundry
I'm looking to create a small movie clip in which I have a small red ball bouncing continuously inside a boundry, I.E. starts off on the left, bounces to the right, hits the right boundry and bounces back to the left, hits left boundry, goes right ... and so it goes on.
I know this is done using AS but am not to sure where to start. If theres a tutorial I could look at or someone who has done this cna help that would be great.
Regards,
Bouncing A Ball With Gravity In As
can someone tell me what is wrong with this code:
Code:
//Values of math
rotate = 5;
xmov = 5;
ymov = 0;
gravity = 2;
neggravity = .001;
frict = 1;
leftbound = 0;
rightbound = 200;
floorbound = 400;
negfrict = .001;
//Replaying function
_root.onEnterFrame = function() {
//Moving the object & applying gravity
speed *= frict;
frict -= negfrict;
ymov += gravity;
gravity -= neggravity;
ball._x += xmov;
ball._y += ymov;
ball._rotation += rotate;
//If statements to check when the ball has exceeded its limit
if(ball._x >= rightbound) {
xmov *= -1;
rotate *= -1;
} else if(ball._x <= leftbound) {
xmov *= -1;
rotate *= -1;
} else if(ball._y >= floorbound) {
ymov *= -1;
} else if(ball._y >= floorbound && ball._x <= leftbound) {
xmov *= -1;
ymov *= -1;
rotate *= -1;
} else if(ball._y >= floorbound && ball._x >= rightbound) {
xmov *= -1;
ymov *= -1;
rotate *= -1;
}
}
it keeps stuffing up as it reaches the bottom. when it does get there it starts bouncing all crazy and weird sorta. ive been trying to fix it for hours. id be really greatful for someone to help me. ive supplied the source fla.
Bouncing Ball Gone Wrong
Hey guys this should be very easy for anyone else but me. Its a simple ball that is supposed to bounce from wall to wall but it just vibrates there! You can find the original FLA here. I'm sure it's a digit or two that need to be changed. Thanks
Come on people, easy stuff here!!
Continuously Bouncing Ball
Hey all, I'm trying to make a ball MC bounce from one wall to the next, coming off at the correct angle, etc. I basically am making a screensaver type of thing. Anyone up for some trig?
Bouncing Ball Into Different Windows
hi,
Need help on how to make a ball bounce into different flash player, the ball continues bouncing wen it has reached the limit of the forst windows nd continues on d other one.
thanks
Animating A Bouncing Ball
Hey I just need a little refresher course here but:
what is the script to animate an object so it bounces to a destination on the screen? I am using Flash CS3.
Bouncing Ball Using AS Tweens
I want a ball to bounce, rotate, and then stop. Not interactive for the user or anything. Im using AS tweens to do it.
my function:
Code:
function bounce() {
ball.tween("_x", 323, .5, "easeOutbounce", 0);
ball.tween("_y", 13, .5, "easeOutbounce", 0);
ball.rotateTo(720,1,"easeoutback");
}
And when the timeline gets to the ball, the code that is used to trigger this is:
Code:
onClipEvent (enterFrame) {
_root.bounce();
}
It dosent work. Have my ball named "ball". I dunno.
Maze With Bouncing Ball.
Hi, I am currently working on a final project for school. I want to make a game where balls are bouncing within a maze, and you have to navigate through without touching the walls or balls.
I don't know how to go about making the balls bounce withing the maze walls. I can make a ball bounce within the stage itself, but I don't know how to make it bounce within the maze walls. Can anyone lead me in some direction.
thanks in advanced.
Randomly Bouncing Ball
In my maze game. I have a part that you have to guess the number of balls in a box, but right after you guess the correct number the balls are stuck for the rest of the game. Is there an actionscript to clear all the balls up.
Bouncing A Ball In A Circle
Hi,
How would you define the outline of a circle, if you wanted to throw a ball in it to bounce off the outline. Thanks alot for your help.
How To Make A Bouncing Ball?
Hello,
I have seen this cool action of a bouncing ball on a couple of flash sites like keldesigned.com
I'm kind of new to Flash MX.. but I can go with the ActionSctipting ^-^.. I would like to know if there's a way to make this fancy action .. i have checked Kiruba's Gravity tut but I want to know how to make the ball squeeze as it hit the ground like the one in the site above
Thank you so much ^-^
OniHime
Ball Is Not Bouncing Off The Wall?
below is the code I am useing I have created a simple frame with 2 layers one named body and one named Code in the code frame I have
// how fast should the ball move?
ballYspeed = 5;
ballXspeed = 5;
onEnterFrame = function () {
// set the speed and position of the ball
ball._y += ballYspeed;
ball._x += ballXspeed;
// if the ball hits the top or bottom
// reverse its Y speed and position
if (ball.hittest(bottom) || ball.hittest(top)) {
ballYspeed *= -1;
}
// if the ball hits the left or right
// reverse its X speed and position
if (ball.hittest(left) || ball.hittest(right)) {
ballXspeed *= -1;
}
};
In the body I have 4 walls all named top bottom right and left they are movies and they are named in there instance the same I have a circle I named ball and made it into a movie and named it ball yet when I run the flash file the ball flys off the page and doesnt bounce inside the boxes? Im confused
[FMX] HELP Bouncing Ball Using Actionscript
hey,
I haven't done much actionscript stuff ...and at the moment im trying to make a ball bounce across the stage, but im unsure how to go about doing that....any help would be much appreciated.
thanks
katey aka "actionscript dummy"
Bouncing Ball/Pong
I'm trying to do some stuff with C# and I figured that the best way to get a pong game set up in that language was to convert from actionscript. Does anyone know some code that will make the ball bounce around the screen or a pong tutorial that explains the ball bouncing code? Thanks.
Ball Bouncing Off Paddle
Hi, could anyone help me with actionscript for a ball boucning off a paddle?
ive managed to get the ball bouncing off the paddle, but now i want to specify which direction the ball should travel depending on which side of the paddle it hits.
This is wat ive written so far: the actionscript for the paddle
onClipEvent(enterFrame) {
{
if (this.hitTest(_root.ball)) //if the movieclip 'ball' hits this movieclip
{
tellTarget(_root.ball) //tell the ball to reverse the X and Y speed, thus
//change directions
{speedX = -speedX;
speedY = -speedY;
}
}
}
}
PLease HELP ME!
Ball Bouncing Off Paddle
Hi im was wondering if anyone knows the script for a ball bouncing off a paddle. I want the ball to bounce off the paddle in different directions depending on:
1) which side of the paddle it hits
2) which direction it came from
Ive only got this so far : script for the paddle
onClipEvent(enterFrame)
{
if (this.hitTest(_parent.ball)) //if this movieclip hits the movieclip 'ball'
tellTarget(_root.ball) //tell the ball to:
{
speedX = speedX; //X speed will stay constant
speedY = -speedY; //Y speed will be reversed (direction is reversed)
Bouncing A Ball In A Circle
Hi,
How would you define the outline of a circle, if you wanted to throw a ball in it to bounce off the outline. Thanks alot for your help.
Ball Is Not Bouncing Off The Wall?
below is the code I am useing I have created a simple frame with 2 layers one named body and one named Code in the code frame I have
// how fast should the ball move?
ballYspeed = 5;
ballXspeed = 5;
onEnterFrame = function () {
// set the speed and position of the ball
ball._y += ballYspeed;
ball._x += ballXspeed;
// if the ball hits the top or bottom
// reverse its Y speed and position
if (ball.hittest(bottom) || ball.hittest(top)) {
ballYspeed *= -1;
}
// if the ball hits the left or right
// reverse its X speed and position
if (ball.hittest(left) || ball.hittest(right)) {
ballXspeed *= -1;
}
};
In the body I have 4 walls all named top bottom right and left they are movies and they are named in there instance the same I have a circle I named ball and made it into a movie and named it ball yet when I run the flash file the ball flys off the page and doesnt bounce inside the boxes? Im confused
[FMX] HELP Bouncing Ball Using Actionscript
hey,
I haven't done much actionscript stuff ...and at the moment im trying to make a ball bounce across the stage, but im unsure how to go about doing that....any help would be much appreciated.
thanks
katey aka "actionscript dummy"
Follow The Bouncing Ball... :)
I am making an animated header/logo for a client.
I am trying to make a ball go "through" a Capital Letter "D", so that it passes through the hole. That means it should pass in front of the bottom, go through the hole, behind the top of the letter and continue on.
I've got my motion guide set up, but I want the ball to "disappear" behind the letter as it goes through the hole. Basically it would be invisible for only a frame.
Any suggestions? Make sense? Is it possible to make it disappear for only a frame?
Thanks in advance for your help!
Tony
Random Bouncing Ball
I have my web page header now with a flash object that has a bouncing ball going up and down.
It's okay for now, but I'd really like to have something that bounces all around my stage / rectangle.
Any suggestions are welcome!
Thanks!
Bouncing Ball Sing Along?
Hello All,
I do a webpage for a school and we have a choir singing a song that I would like to do something creative with. I wanted to put it into flash and do a sort of sing along with a ball bouncing on top or the words as they are sung. Does anyone have any idea on how to go about this?
Thanks,
Ramon
Dynamic Bouncing Ball Within Its Own MC?
Well, I'm supposed to present this exercise before the class tomorrow in which we use actionscripting to create user defined incremental loops, as well as textfields to display data. Well, my idea was to create this bouncing ball that would bounce around the screen (taking reflective angles, random speed, random direction) with textfields to display its x/y coordinates, and then let the viewer choose how many they want on the screen.
Well, I got the ball bouncing perfectly, and the textfields display the x/y coordinates just the way I want, but it's all out in the scene. I want to put all of this into a movieclip, so that I can use duplicateMovieClip in a for loop. I've tried moving the content into a movieclip, but the paths must be changed. I went and made what I thought were the apropriate path changes, but it still won't work.
All the source and swf files are at my class project page. Here's the run down of the versions:
Exercise 2.3 is the last successful version, with the ball that bounces around perfectly.
Exercise 2.4 is screwed up because I tried to take out all the "Number()" statements, since I believe that's old code and isn't necessary in flash mx (am I wrong? please correct me).
Exercise 2.5 is version 2.3 that was moved into a single movie clip called "bounce", with modified paths to suit.
It would be really awesome if I just have some little thing screwed up and it can all work within one movie clip, cause that will make my life a lot easier. I'll be working on it tomorrow morning before class, so I'll definately check back before then.
PS: I know just saying "_root.bounce.whatever" will screw up my duplication of the MC "bounce". I'll need to name them incrementally (bounce + i), but am not sure how I will handle that within the seperate movie clips themselves... it's a bit of a logic fart.
Return Bouncing Ball? - FLASH 5
hi, i have a ball bouncing along the stage by using this code:
code:
onClipEvent (load) {
vy = -8;
}
onClipEvent (enterFrame) {
_rotation += .25;
_x -= 3;
vy *= 0.99;
vy += .25;
if ((_y+_width/2)>400) {
vy *= -0.85;
}
_y += vy;
}
this works just how i want it to. what i cannot figure out is how would i make the ball go by the screen more than once. i need the ball to bounce by the screen and then once it's x position is greater than 0 it will go back to its old coordinates and bounce by again. here is an fla to show you.
its a flash 5 file
|