|
|
|||||
Topic, Sharing AS3 Classes | ||||||
| ||||||
You must register or log in to post a message.Now you can get a ratio of progress for the timer: using t/duration will give you a decimal value between 0 and 1, where 0 means the timer has just begun, and 1 means the timer has finished. Now, you must use an interpolation function to mix between the start value and end value. For example: So, say you want to move the player from x=100 to x=200 over a period of 2 seconds, you can do something like this: Basically, I want to create a function a bit like the Scratch function: glide from [ start ] to [ finish ] in [ time ] I set up a class and calculated distances x & y between the start and finish points. However, I need some sort of formula to work out the length of the average line (an angle bisector of 90 degrees) based on my distance x and y. Thanks! :) [EDIT] Never mind, figured out a way simpler solution. MathUtils() [Throws an Error] average(a:Array) [Returns the average of the numbers in an array] formatAsCurrency(c:String, n:Number, english:Boolean, decimal:Boolean) [See FlxU.formatMoney() - c = the symbol] formatAsDate(d:Date) [Returns a String along the lines of "Monday 3rd September 2012"] formatAsTime(d:Date, seconds:Boolean, showGMT:Boolean) [Returns a string along the lines of "14:31:00 (GMT +1)"] roundToNearest(n:Number, r:Number) [Returns an integer.] Other functions MathUtils has are used by other functions, such as formatAsDate() uses getWeekday(). If you want to work on it with me, I'll create a shared folder for it on DropBox. I was making a library to help with games as a whole - utilities that could take forever to script in a game - especially when you want to keep the file size down. For Beginners: Object Oriented Programming in AS3 At the moment, I'm sticking with Game as the prefix. The idea of the library is to help with making Games that involve level data serialization (e.g. BL Games). I'm not sure whether it's very good, I'd just like feedback infact, but I decided to code an Animation Engine in AS3. It's not that user friendly, but I just want to know: a) Whether my code is right. b) Is it actually useful. It was targeted at the FlashDevelop Community, even though this was made in Flash CS6, due to the fact that everything has to be coded, and so there's no drawing MovieClips or IK. Parameters & Functions PRIVATE: EMPTY_OBJECT (An Empty MovieClip) PRIVATE: MOVIE_LIST (An Array storing all MovieClips) PRIVATE: TOTAL_FRAMES (Total Frames of the MovieClip) CONSTRUCTOR: Animation(empty_object:MovieClip, movie_list:Array, total_frames:int) The class also includes 7 other functions (one private, containing a 'for' loop) and the others for timeline control, such as gotoAndStop(); Download Animation.as Next Updates - No need to supply an Empty MovieClip - More Suggestions Welcome if your internet is down it wont work... It's a static class, so goofy names won't work. :S @Gecko: Also, you said throwing exceptions was good practice. How come you didn't throw an exception for your constructor function in your "Keys" class? Edit: You'll need Array.reverse(); if you want to sort them Chronologically, it does it backwards! BTW I love making games. I'm thinking about making a very useful class, a basic editor class that I will use, that extends from MyEditorManager. You can enhance the code in any way you like, to your specifications, and before you aks "WHERE DA F*** IS THE LINK?" there isn't one, becuase it hasn't been made yet. :) I used the mail function in PHP, that's how it actually e-mails people. It's no good adding it to a website. Both HTML, PHP and Javascript have easy e-mail functions available. There's no reason to add it to a standalone .swf because... Well, why would you? Email [V.0.1] AS3 by Manufan. @Birjo: Epic! I will post my code soon And some example code. For an actual example of it in action, see this. | Flash game developmentFirst post of the topicIf you are still using AS2, I highly recommend downloading the free Flex SDK and FlashDevelop tools. There's a great tutorial on the FlashPunk site. AS3 SFXR is great tool for making video game sound effects. Use the interface to perfect your noise, then use the free SfxrSynth class to generate and play your sounds on the fly without importing any .wav files! Magic. Flixel and FlashPunk (thanks to JP for pointing them out) are both libraries which allow you to make sprite-based games easily by extending the base classes. Calista is a collection of cryptography classes. You will need a SVN client to download it though, or you could use the source browser to copy the files individually. Tweener will help you to move things around the stage smoothly using only code. Great when you're using Flex. |