STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229494
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2575 · P5149

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/13486394?noj=FRM13486394-14DC" width="1" height="1"></div>

Simple Gravity Tutorial.swf

This is the info page for
Flash #76799

(Click the ID number above for more basic data on this flash file.)


Text
Gravity Tutorial

Creating Gravity in flash games and applications

Start

Start

Credits

Credits

Sound Credits
Sound design magical accent swell harp twinkle sparkle science fiction 01
Created By: SFX Bible
Dark Atmosphere
Created By: celso cano
www. soundsnap.com

Welcome to my Gravity Tutorial. In this tutorial im planning to teach you how
to create a simple  gravity effect.
So lets set up for the simple gravity effect.
Lets think about gravity in reality. When we drop a pen, what happens?
It continues to gain velocity untill it hits the ground.

Next

Ok, to start, lets make a simple ball fall to a certain y-position on the screen
before the ball stops where we will have a invisible floor.
Create a ball object such as this
And  turn it into a movieClip with an instance name of redBall
Then right afterwards we are ready for the script! phew what a effort!

Now we have the ball ready, open up your actions tab for some coding fun!
In the code, we will need to implement some code setting the gravity
(the rate the speed will increase as it falls) and the fall velocity.
onClipEvent(load)
{
gravity = 1;//sets the speed the ball will fall at
fallVelocity = 0;//sets the starting velocity
}
onClipEvent(enterFrame)
{
fallVelocity +=gravity;//increases the rate the ball will fall at
this._y +=fallVelocity;//uses the prvious variable to change it accordingly
}

You would of noticed when you played it, the ball didnt stop, but kept
on falling forever. We are going to make it so it falls and stops at the
bottom of the stage now. Change the code to the following
onClipEvent(load)
{
gravity = 1;//sets the speed the ball will fall at
fallVelocity = 0;//sets the starting velocity
}
onClipEvent(enterFrame)
{
fallVelocity +=gravity;//increases the rate the ball will fall at
this._y +=fallVelocity;//uses the prvious variable to change it accordingly
if((this._y+this._height/2) > Stage.height)
{
this._x=Stage.height - (this._height/2);
fallVelocity = 0;
}
}

So there you have it! a simple way to implement gravity.  Fomr here, you could
try to implement this in any number of types of games and software and can
easily be modified for all sorts of things. Enjoy!

ActionScript [AS1/AS2]

Frame 2
stop(); if (isNaN(firstload)) { creditOpen = 1; firstload = 9; i = 0; while (i < 500) { prevValue = i - 1; _root["star" + prevValue].duplicateMovieClip("star" + i, this.getNextHighestDepth()); i++; } _root.page = 1; var buttonsnd = new Sound(); var snd = new Sound(); buttonsnd.attachSound("twinkle"); snd.attachSound("Dark_atmosphere"); _root.snd.start(0, 999); }
Instance of Symbol 23 MovieClip "star0" in Frame 2
onClipEvent (load) { this._x = random(550); this._y = random(400); alphaModifier = -1; maxAlpha = random(100); this._alpha = maxAlpha; } onClipEvent (enterFrame) { this._alpha = this._alpha + alphaModifier; if (this._alpha < 10) { alphaModifier = 1; } if (this._alpha > maxAlpha) { alphaModifier = -1; } }
Instance of Symbol 38 MovieClip "creditsList" in Frame 2
onClipEvent (enterFrame) { if (_root.creditOpen < 1) { this._x = this._x + 10; if (this._x > (Stage.width / 2)) { this._x = Stage.width / 2; } } }
Instance of Symbol 40 MovieClip "redBall" in Frame 2
onClipEvent (load) { counter = 48; gravity = 1; fallVelocity = 0; } onClipEvent (enterFrame) { fallVelocity = fallVelocity + gravity; this._y = this._y + fallVelocity; if ((this._y + (this._height / 2)) > Stage.height) { this._y = Stage.height - (this._height / 2); fallVelocity = 0; } if ((this._y + (this._height / 2)) >= Stage.height) { counter--; } if (counter < 1) { counter = 48; this._y = 96; } }
Frame 3
stop();
Frame 4
stop();
Frame 5
stop();
Instance of Symbol 40 MovieClip "redBall" in Frame 5
onClipEvent (load) { this.gravity = 0.2; this.fallVelocity = 0; } onClipEvent (enterFrame) { this.fallVelocity = this.fallVelocity + this.gravity; this._y = this._y + this.fallVelocity; if (this._y > Stage.height) { this.fallVelocity = 0; this._y = 96; } }
Frame 6
stop();
Instance of Symbol 40 MovieClip "redBall" in Frame 6
onClipEvent (load) { counter = 48; gravity = 1; fallVelocity = 0; } onClipEvent (enterFrame) { fallVelocity = fallVelocity + gravity; this._y = this._y + fallVelocity; if ((this._y + (this._height / 2)) > Stage.height) { this._y = Stage.height - (this._height / 2); fallVelocity = 0; } if ((this._y + (this._height / 2)) >= Stage.height) { counter--; } if (counter < 1) { counter = 48; this._y = 96; } }
Frame 7
stop();
Symbol 11 Button
on (release) { getURL ("http://www.newgrounds.com", "_blank"); }
Symbol 20 Button
on (release) { _root.play(); }
Symbol 21 MovieClip Frame 1
function timerHandler() { if (!loadingComplete) { var _local2 = _root.getBytesLoaded() / _root.getBytesTotal(); bar._xscale = 100 * _local2; if (_local2 == 1) { loadingComplete = true; if (AUTO_PLAY) { startMovie(); } else { gotoAndStop ("loaded"); } return(undefined); } } } function startMovie() { _root.play(); } _root.stop(); stop(); var AUTO_PLAY = false; var loadingComplete = false; timerHandler();
Instance of Symbol 12 MovieClip in Symbol 21 MovieClip Frame 1
onClipEvent (enterFrame) { _parent.timerHandler(); }
Symbol 21 MovieClip Frame 2
stop();
Symbol 32 Button
on (release) { _root.buttonsnd.start(0, 1); play(); _root.creditOpen = 3; _root.page++; }
Symbol 36 Button
on (press) { _root.creditOpen = 0; }
Symbol 46 Button
on (press) { gotoAndStop (4); }
Symbol 48 Button
on (press) { gotoAndStop (5); }
Symbol 51 Button
on (press) { gotoAndStop (6); }
Symbol 54 Button
on (press) { gotoAndStop (7); }
Symbol 56 Button
on (press) { gotoAndStop (2); }

Library Items

Symbol 1 Sound [twinkle]
Symbol 2 Sound [Dark_atmosphere]
Symbol 3 GraphicUsed by:21
Symbol 4 GraphicUsed by:5
Symbol 5 MovieClipUses:4Used by:21
Symbol 6 GraphicUsed by:21
Symbol 7 GraphicUsed by:10 11
Symbol 8 GraphicUsed by:10 11
Symbol 9 GraphicUsed by:10 11
Symbol 10 MovieClipUses:7 8 9Used by:11
Symbol 11 ButtonUses:10 7 8 9Used by:21
Symbol 12 MovieClipUsed by:21
Symbol 13 GraphicUsed by:21
Symbol 14 GraphicUsed by:20
Symbol 15 GraphicUsed by:20
Symbol 16 GraphicUsed by:20
Symbol 17 GraphicUsed by:20
Symbol 18 GraphicUsed by:20
Symbol 19 GraphicUsed by:20
Symbol 20 ButtonUses:14 15 16 17 18 19Used by:21
Symbol 21 MovieClipUses:3 5 6 11 12 13 20Used by:Timeline
Symbol 22 GraphicUsed by:23
Symbol 23 MovieClipUses:22Used by:Timeline
Symbol 24 FontUsed by:25 27 28 30 33 35 37 41 44 47 53 55 57
Symbol 25 TextUses:24Used by:26
Symbol 26 MovieClipUses:25Used by:Timeline
Symbol 27 TextUses:24Used by:Timeline
Symbol 28 TextUses:24Used by:29 32
Symbol 29 MovieClipUses:28Used by:32
Symbol 30 TextUses:24Used by:31 32
Symbol 31 MovieClipUses:30Used by:32
Symbol 32 ButtonUses:28 29 31 30Used by:Timeline
Symbol 33 TextUses:24Used by:34 36
Symbol 34 MovieClipUses:33Used by:36
Symbol 35 TextUses:24Used by:36
Symbol 36 ButtonUses:33 34 35Used by:Timeline
Symbol 37 TextUses:24Used by:38
Symbol 38 MovieClipUses:37Used by:Timeline
Symbol 39 GraphicUsed by:40
Symbol 40 MovieClipUses:39Used by:Timeline
Symbol 41 TextUses:24Used by:Timeline
Symbol 42 GraphicUsed by:43
Symbol 43 MovieClipUses:42Used by:Timeline
Symbol 44 TextUses:24Used by:45 46 48 51 54 56
Symbol 45 MovieClipUses:44Used by:46 48 51 54 56
Symbol 46 ButtonUses:44 45Used by:Timeline
Symbol 47 TextUses:24Used by:Timeline
Symbol 48 ButtonUses:44 45Used by:Timeline
Symbol 49 GraphicUsed by:50
Symbol 50 MovieClipUses:49Used by:Timeline
Symbol 51 ButtonUses:44 45Used by:Timeline
Symbol 52 FontUsed by:53 55 57
Symbol 53 TextUses:24 52Used by:Timeline
Symbol 54 ButtonUses:44 45Used by:Timeline
Symbol 55 TextUses:24 52Used by:Timeline
Symbol 56 ButtonUses:44 45Used by:Timeline
Symbol 57 TextUses:24 52Used by:Timeline

Instance Names

"star0"Frame 2Symbol 23 MovieClip
"creditsList"Frame 2Symbol 38 MovieClip
"redBall"Frame 2Symbol 40 MovieClip
"redBall"Frame 5Symbol 40 MovieClip
"redBall"Frame 6Symbol 40 MovieClip
"bar"Symbol 21 MovieClip Frame 1Symbol 5 MovieClip

Special Tags

FileAttributes (69)Timeline Frame 1Access local files only, Metadata not present, AS1/AS2.
ExportAssets (56)Timeline Frame 1Symbol 1 as "twinkle"
ExportAssets (56)Timeline Frame 1Symbol 2 as "Dark_atmosphere"

Labels

"loaded"Symbol 21 MovieClip Frame 2




http://swfchan.com/16/76799/info.shtml
Created: 4/4 -2019 13:38:32 Last modified: 4/4 -2019 13:38:32 Server time: 14/11 -2024 07:16:43