Be a Supporter!

AS: Physics Ball

  • 1,038 Views
  • 14 Replies
New Topic Respond to this Topic
loopchocolateman1234
loopchocolateman1234
  • Member since: Jul. 19, 2008
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
AS: Physics Ball Jul. 28th, 2011 @ 05:11 PM Reply

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:

onClipEvent (load) {
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!

AS: Physics Ball


LOL! ^_^

BBS Signature
Xeptic
Xeptic
  • Member since: May. 12, 2005
  • Offline.
Forum Stats
Member
Level 32
Game Developer
Response to AS: Physics Ball Jul. 28th, 2011 @ 05:22 PM Reply

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


BBS Signature
milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Online!
Forum Stats
Member
Level 26
Programmer
Response to AS: Physics Ball Jul. 28th, 2011 @ 05:27 PM Reply

Nobody needs your As1 crap.

fail.

Spysociety
Spysociety
  • Member since: Dec. 30, 2009
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to AS: Physics Ball Jul. 28th, 2011 @ 05:55 PM Reply

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 Jul. 28th, 2011 @ 06:23 PM Reply

o yeah sry

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

Please go check it out for more information!


LOL! ^_^

BBS Signature
Darnose
Darnose
  • Member since: Apr. 4, 2010
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Physics Ball Jul. 29th, 2011 @ 02:07 AM Reply

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 Jul. 29th, 2011 @ 02:24 AM Reply

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 Jul. 29th, 2011 @ 02:41 AM Reply

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 Aug. 1st, 2011 @ 09:38 PM Reply

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


LOL! ^_^

BBS Signature
MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Online!
Forum Stats
Member
Level 10
Programmer
Response to AS: Physics Ball Aug. 1st, 2011 @ 10:20 PM Reply

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.

BBS Signature
PSvils
PSvils
  • Member since: Feb. 3, 2010
  • Offline.
Forum Stats
Member
Level 01
Game Developer
Response to AS: Physics Ball Aug. 2nd, 2011 @ 01:54 PM Reply

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 Aug. 3rd, 2011 @ 06:33 PM Reply

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 Aug. 3rd, 2011 @ 06:48 PM Reply

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
  • Online!
Forum Stats
Member
Level 10
Programmer
Response to AS: Physics Ball Aug. 3rd, 2011 @ 07:43 PM Reply

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.

BBS Signature