## AS: Physics Ball

• 1,432 Views
• 14 Replies
loopchocolateman1234
loopchocolateman1234
• Member since: Jul. 19, 2008
• Offline.
Forum Stats
Member
Level 12
Blank Slate
AS: Physics Ball 2011-07-28 17:11:11

Instructions:

First of all, create a Circle using the Oval Tool. (Add whatever color or texture you want). Then right click the Circle and find on the pop-up menu "Convert To Symbol...". Press it then a menu should appear, make sure Movie Clip is filled in, name your Movie Clip "Physics Ball_mc". Now make sure that the ball isn't the world's smallest object, (what I'm trying to say is don't make it too small or big). Select the ball and enter in this Action Script. NOTE: Also change the Frame rate to 120 FPS to get the best speed for the ball. For the action script just copy and paste from here to the ball.

Action Script:

var acceleration = 0.005;
var termVelocity = 20;
var yVel = 0;
var xVel = 0;
var e = 0.8;
var f = 0.8;
var dragged = 0;
}
onClipEvent (enterFrame) {
if (this._y<380) {
if (dragged == 0) {
yVel += (termVelocity-yVel)*acceleration;
}
} else if (this._y>380) {
yVel *= -1*e;
xVel *= f;
this._y = 380;
}
if (this._x>530) {
xVel *= -1*e;
yVel *= f;
this._x = 530;
} else if (this._x<20) {
xVel *= -1*e;
yVel *= f;
this._x = 20;
}
if (dragged == 0) {
this._y += yVel;
this._x += xVel;
}
}
on (press) {
this.startDrag(false);
dragged = 1;
velocity = 0;
xVel = 0;
}
on (release, releaseOutside) {
this.stopDrag();
dragged = 0;
}

Hope this helped!

Enjoy!

LOL! ^_^

Xeptic
Xeptic
• Member since: May. 12, 2005
• Offline.
Forum Stats
Member
Level 32
Game Developer
Response to AS: Physics Ball 2011-07-28 17:22:31

I do believe you're supposed to explain how and why this works. Copy/pasting code doesn't really help people to learn AS.

milchreis
milchreis
• Member since: Jan. 11, 2008
• Offline.
Forum Stats
Member
Level 26
Programmer
Response to AS: Physics Ball 2011-07-28 17:27:34

Nobody needs your As1 crap.

fail.

MCarsten
MCarsten
• Member since: Dec. 30, 2009
• Offline.
Forum Stats
Member
Level 21
Programmer
Response to AS: Physics Ball 2011-07-28 17:55:05

You forgot to type:
"Codes by lozman2k3k, from 2D Physics Tutorial"

loopchocolateman1234
loopchocolateman1234
• Member since: Jul. 19, 2008
• Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Physics Ball 2011-07-28 18:23:34

o yeah sry

And codes from Codes by lozman2k3k, from 2D Physics Tutorial

LOL! ^_^

Darnose
Darnose
• Member since: Apr. 4, 2010
• Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Physics Ball 2011-07-29 02:07:29

Sorry, but may I ask what version of AS3 this is? I don't like bringing people down, but I doubt it will to you, but it seems like it's AS1. Not many people here, including me, use AS1 anymore. It is absolutely nonstandard. I use AS3 and SOMETIMES AS2, and overall AS3 is the most standard version that I've programmed with. Like how you share source that you find interesting, but not really helpful to the modern programmers. I'm not trying to be mean, but just saying.

A great site to make you laugh: Parodies

HAROfficial
HAROfficial
• Member since: Jun. 16, 2011
• Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Physics Ball 2011-07-29 02:24:15

At 7/29/11 02:07 AM, Darnose wrote: Sorry, but may I ask what version of AS3 this is? I don't like bringing people down, but I doubt it will to you, but it seems like it's AS1. Not many people here, including me, use AS1 anymore. It is absolutely nonstandard. I use AS3 and SOMETIMES AS2, and overall AS3 is the most standard version that I've programmed with. Like how you share source that you find interesting, but not really helpful to the modern programmers. I'm not trying to be mean, but just saying.

I think you mean 'What version of AS is this.' XD
It is AS1 and I mean, seriously, who copies code and pastes here. That's just rude.

Stage3D is awesome.

Darnose
Darnose
• Member since: Apr. 4, 2010
• Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Physics Ball 2011-07-29 02:41:50

At 7/29/11 02:24 AM, HAROfficial wrote: I think you mean 'What version of AS is this.' XD
It is AS1 and I mean, seriously, who copies code and pastes here. That's just rude.

I know I did a type :)

Also, agree with what you said.

A great site to make you laugh: Parodies

loopchocolateman1234
loopchocolateman1234
• Member since: Jul. 19, 2008
• Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Physics Ball 2011-08-01 21:38:21

It's AS2, I use on flash 8...

LOL! ^_^

MintPaw
MintPaw
• Member since: Jun. 11, 2006
• Offline.
Forum Stats
Member
Level 10
Programmer
Response to AS: Physics Ball 2011-08-01 22:20:29

At 8/1/11 09:38 PM, loopchocolateman1234 wrote: It's AS2, I use on flash 8...

You're allowed to write AS1 code in AS2, what you have there is AS1.

If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

PSvils
PSvils
• Member since: Feb. 3, 2010
• Offline.
Forum Stats
Member
Level 01
Game Developer
Response to AS: Physics Ball 2011-08-02 13:54:12

Regardless of whether it's AS1 or AS2, you basically copied someone elses tutorial code, and passed it on as your own, conveniently "forgetting" to mention the original author...

Fuckin shame...I bet you don't even know how to program this from scratch on your own.

loopchocolateman1234
loopchocolateman1234
• Member since: Jul. 19, 2008
• Offline.
Forum Stats
Member
Level 12
Blank Slate
51lver
51lver
• Member since: Jan. 14, 2008
• Offline.
Forum Stats
Member
Level 24
Blank Slate
Response to AS: Physics Ball 2011-08-03 18:33:32

I like the part where you think you're being clever and giving people unhelpful code to learn from :)

1Kingfire1
1Kingfire1
• Member since: Dec. 16, 2007
• Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Physics Ball 2011-08-03 18:48:44

It's not really related to this, but didn't want to make a new post.

Been looking round the internet for advanced physics tutorials, like the collisions and physics in angry birds. Any of you know where I can find some learning material?

Want to increase knowledge in programming. If you need someone to program something, I will be happy to help for free :) .

MintPaw
MintPaw
• Member since: Jun. 11, 2006
• Offline.
Forum Stats
Member
Level 10
Programmer
Response to AS: Physics Ball 2011-08-03 19:43:25

At 8/3/11 06:48 PM, 1Kingfire1 wrote: It's not really related to this, but didn't want to make a new post.

Been looking round the internet for advanced physics tutorials, like the collisions and physics in angry birds. Any of you know where I can find some learning material?

Well what you're probably looking for is a full blown physics engine. Look up box2d. If you're not already experienced in as3 then forget it.

If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.