-
Physics Actionscript - Help Please
Hi, I need some help with one of my flash projects.
I'm trying to write some actoionscript that will make a ball movieclip fall (and accelerate until a certain speed, like real gravity), and when it hits a ground movieclip it will bounce at the right angle if the ground is a slope and will roll down. I don't want the ball to bounce that much, so it doesn't really matter, but I've got gravity and collision detect code but how can I put it together and make it almost look real?
Please help me, I'm kinda new to this stuff (physics in actionscript) and could really do with the help.
Thanks
-
Senior Member
Do you want to post the code you have, and then we can figure out how to put it together?
It's a pretty simple problem. It just depends how you're integrating it with the rest of the game. So post the code.
-
This is the gravity code. That's it, I think i deleted the rest of it, I just got this off the site I got it off before.
gravity = 1;
accelerate = gravity;
ball.onEnterFrame = function () {
accelerate++;
ball._y += gravity+accelerate;
if (ball._y >= 420) {
ball._y = -20;
}
if (accelerate >= 70) {
accelerate--;
}
}
I sort of need the same thing as the pinball physics thread above.
-
well cut this bit out you dont need it because you want collision dection this will just make its y pos go to -20 on the stage once it reaches pos 420 on the stage:
if (ball._y >= 420) {
ball._y = -20;
}
you got and hit test code yet??
-
...
I'm sorry I can't find it, so that's it. Don't bother if you wnat me to give you anything else, but I will try again and post the best I can find.
-
well learn basic hit tests first
-
I know it, but i need to work out the angle to make it bounce off etc., I'm not new to everything flash, just physics.
-
When in doubt ask
<signature removed by admin>
-
Senior Member
Hey Eager Beaver,
You really are eager, but as a suggestion, posting your work 4 times on the same thread will only discourage people from looking at it...
-
When in doubt ask
Originally Posted by ozmic66
posting your work 4 times on the same thread ...
I have posted only twice that too in two different threads.
The referred FLA was downloaded more than 1900 times, which
has been an excellent encouragement.
My advice to you: Please stop acting as a moderator, which you are not!
Last edited by Eager Beaver; 02-26-2007 at 02:29 AM.
<signature removed by admin>
-
Originally Posted by Eager Beaver
The referred FLA was downloaded more than 1900 times, which
has been an excellent encouragement.
lulz
-
Senior Member
Originally Posted by Eager Beaver
I have posted only twice that too in two different threads.
The referred FLA was downloaded more than 1900 times, which
has been an excellent encouragement.
My advice to you: Please stop acting as a moderator, which you are not!
Yea, great, thanks for the tip
At least I got a good laugh out of it
-
Hey, i dont know if your still playing around to get the ball to work..
Here is a great tutorial on bouncing balls at bit 101.. http://www.bit-101.com/tutorials/gravity.html
That is what got me into physics and then i bought his book on actionscript Actionscript Animation: Making things move In the book he explains almost everything you will need to know about gravity, velocity.etc and even explains how to get balls to bounce off angles. To get balls to bounce off angles you will need to calculate the angle that the ball has hit the surface then rotate the angle so it is flat, calculate the angle that it will bounce off at then rotate it all back.
If you don't understand that, i highly recommend that you get that book.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|