Free ActionScript
Home
AS3 Scripts
AS2 Scripts
Resources
About
Contact
This Flash game example shows you how to create smooth 4-way player movement with acceleration & friction. This fla also shows you how to create a screen-wrap effect (think asteroids).
Custom Settings:
max velocity
acceleration
friction
Preview
Download Fla Sample
only thing those who use this might wish to add is
if(velocityX || velocityY < aLowNumber){ velocityX and velocityY =0; }
just to stop the drift that happens as they come to a stop, 0.00846 is just enough for distract your eye.
The author of this site is truely an awesome. I use his as2 works as inspiration for my as3 works
That’s a very good suggestion EightySeven.
It’s a good idea to use a “stopper” for everything that moves. If you’re moving something less than 0.05 pixels for example, it doesn’t move visually, but flash is still redrawing everything in the background using up CPU cycles.
Thanks for the complement!
I tried to copy and paste EightySeven’s code into my project but it didn’t work, so I wrote my own:
if(velocityX < 0.05 && velocityX > -0.05){ velocityX = 0; } if(velocityY < 0.05 && velocityY > -0.05){ velocityY = 0; }
It’s also AS2, so it’ll work for all you who haven’t migrated to AS3 yet.
- Noah
Thanks NoahJ!
You must be logged in to post a comment.
AS3 Effects
AS3 Gadgets
Game Examples AS2 Effects Animated Effects Dynamic Enemy AI Game Engine Game Weapons Images Interface Math Security
Effects Animated
Effects Dynamic
Enemy AI
Game Engine
Game Weapons
Images
Interface
Math
Security
Game Examples AS3 Basics Bitmap Blitting Collision Detection Enemy AI Movement Physics Space Shooter User Interface Weapon System
Basics
Bitmap Blitting
Collision Detection
Movement
Physics
Space Shooter
User Interface
Weapon System
Site Updates
718Hosting.com
Actionscript.org Forums
Flash Game Blogs
Flash Game License
Flashkit Forums
gotoAndLearn
IndieGames.com
Kirupa’s Tutorials
Kongregate Forums
MochiAds Resources
Philip Radvan
Photon Storm
Polygonal
Radvan Media
Tonypa’s Tutorials
Register
Log in
Entries RSS
Comments RSS
WordPress.org