Actionscript 3 Sprite Trails

     I need a simple sprite with a small trail for a game i'm working on so i had to create some way of tracking sprites and giving them a trail. Heres the simple demo i've created - i wonder if someone could turn it into a game idea? It's just some round blobs "swimming" from left to right. It's pretty rough, but atleast you can see what i mean by sprite "trails".

Actionscript 3 Animated Sprite Engine Library

     Finally had time for an update! Here are the animated sprite classes that i've mention before, which are being used in my nearly finished game. I've done some basic testing and built the main base for my animation system (i'll extend it to animated tiles for backgrounds later). I couldn't find an animated bitmap class on the web for Actionscript 3 that i could use for my specific requirements - so i've made my own. Heres a quick run down of the features:

  • Simple XML animation format
  • Unlimited number of "states" to define different actions for each sprite
  • Each frame can be any size rectangle, located anywhere on the animation image (not just repeating rectangles like most systems)
  • Possiblity to have huge sprites (can use multiple images for a single sprite - only limited to 2880 bitmap size maximum per asset)
  • A frame can be located anywhere on the image and can reuse a frame multiple times in a single state aswell as across multiple states
  • Optional handle/hotspot for handling sprites instead of top left
  • Minimizes overdraw by specifying smallest rectangles not just fixed width & size for each frame (handy for bin packing images)
  • No loop, normal looping or ping-pong style animation looping
  • Play animation forwards or backwards
  • Start animation at any frame, and jump to any frame
  • Allows both animated sprites & bitmaps (sprite has a child bitmap)
  • Clone animatedBitmaps to save processing the XML file multiple times
  • FRAME_CHANGED and ANIMATION_COMPLETE events
  • Play animation once, loop animation infinitely or specify number of loops
  • Each frame can have a specific number of milliseconds delay, allowing fine control over complex animations
  • Sprite animation playback speed can be adjusted to slowdown or speedup the whole animation on the fly
  • Set current state by statename as well as index
  • Uses ENTER_FRAME instead of timers for animation update (useTimer option if you want to use timers for specific animations)
  • Stagelayer object to separate animated sprites/bitmaps into layers (needed for ENTER_FRAME and handy for collisions)
  • 4 Different Rendering methods for memory use vs speed (and for different requirements as one type doesn't fit all)
    • FRAME_BUFFER_REFERENCE (uses original bitmapData & scrollRect)
    • FRAME_BUFFER_OVERSIZED (uses a single growing bitmapData & copyPixels)
    • FRAME_BUFFER_CACHED (uses a seperate bitmapData for each frame & caches it when first generated with copyPixels)
    • FRAME_BUFFER_UNIQUE (uses a new bitmapData & copyPixels everytime the frame changes)
  • Uses frame time delta with smoothing for smoother animation (includes option to turn it off)

Just purchased Flex Builder from Adobe

     Just a quick update - i've been absent for a short while, getting snowed under with real life! But i'm back now, so lets get ready to rummmmmmble! I now own a fully paid for copy of Flex Builder 3 - although i will still be using FlashDevelop as i really like it, i wanted to support Adobe, and also have a play with the flex designer in eclipse.

Flex Builder 3 Standard Edition

Plans for this blog and actionscript programming

     I've finally decided what to focus on with this blog - developing a general purpose game library to assist in helping people make games easier. I'm actually writing a lot of base code to use in my own games (like the hittest function i blogged about earlier). At the moment, i can't find a decent fairly complete set of libraries to do basic things needed for games in actionscript 3. Theres a lot of good stuff out there, but none of it is integrated with anything else, so you have to spend a fair bit of time hacking things together. So i've changed my mind as to this blog's use - i was going to use it to post snippets of code here and there when i found out things in AS3 to help someone learn it like i am doing, but theres quite a few sites out there doing that already and plus you can't really produce lots of really helpful code in small snippets.

AS3 Preloader With MochiAd, MochiBot, Simple Domain Locking and Glossy Vista Style Progress Bar

     As promised in my last blog entry, heres my version of an AS3 preloader. It's the second time i've typed this out, as the first time i had lost my cookies while messing around in another firefox window and when i came to post this entry it just said access denied and it had all gone! Lovely! Anyway the main points of my preloader are

  • MochiAds & MochiBot already integrated
  • Simple domain site locking implemented
  • Nice glossy style progress bar
  • Reusable code, not integrated heavily into a project
  • Easy to add to existing AS3 project
  • Pure AS3 classes
  • Works with FlashDevelop or Flex Builder
  • Minimal Delays, fairly small size

And most of all i'm giving all the source code away, not just snippets :)

Vista Glossy Progress Bar In Actionscript 3

     This time i wanted to make a nice progress bar for the preloader i've made. First of all, the usual check of Google. Plenty of hits, mostly for AS2 - a few for AS3 but nothing that takes my fancy. I did see a nice turning "barbershop pole" stripe bar, which i started out aiming for but before i'd written much code i figured a nice thing to do would be to simulate the nice glossy progress bars seen in windows vista. If it hasn't got anything else right, it has nice progress bars. Even though they still run on "microsoft time" and hardly give you a good indication of how long something is going to take, they do stand out and look the business.

Cleaning Up After Yourself In Actionscript 3 (Lack Of Class Destructors)

     Haven't written anything on here in a few days, been busy learning more AS3 and getting on with my 2 current game projects. I've got a list of things todo, plus some things i've found out about actionscript as i'm learning which might be helpful to others.

     My background is from all sorts of programming, i think a rough list is BASIC, PASCAL, AMOS, BLITZBASIC, AREXX, ASM (680x0), C, C++, ASM (80x86), LUA and now Actionscript 3. Having spent a lot of time with C++ and Delphi (oop pascal) i've got quite used to doing things in a certain way. Actionscript 3 in Flash 9 is pretty good so far, certainly i could never have created anything useful in flash previously - i think i have two left thumbs ;). I can just about "operate" paintshop pro/photoshop, but haven't really produce anything i'd be in a hurry to show! So flash and it's designer friendly interface wasn't for me. Since choosing AS3 as my new language to work on, it's been a slow start - but getting better, theres a definite way to do things with is a bit different. 

Actionscript 3 hitTestObject and Pixel Perfect Collision Detection

     For a flash game project, i needed to see if a number of sprites had collided. I soon found out that hitTestObject doesn't support perfect collisions for non-shape sprites, so i needed another solution.

     After wasting some time discovering hitTestObject only supports bounding rectangles for non shape sprites, i needed to find a pixel perfect collision detection method that worked on any sprites. One of the ways i've done it in the past is quite common, and has been used a lot over the years. You can approximate most sprites fairly well using a series of circles to form a collision detection area. Then it's fairly easy and reasonably fast to see if any circles have collided. This time however, i wanted to use pixel perfect accuracy, but i wasn't sure if flash was powerful enough to cope with such a task. It turns out that Flash Player 9 and actionscript 3 handle the job reasonably well with a clever bit of code from some smart cookies.

Getting Started With Actionscript 3

A little howto on setting up your open source AS3 programming IDE, what to download and some installations tips!

      So you want to start programming in actionscript, outside of Adobe CS3? I'd recommend trying FlashDevelop. I use it for all my flash/flex development at the moment, and even when i purchase CS3 or Flex i'll probably still use FlashDevelop for pure coding. It offers a very clean interface, works well and doesn't have to much in the way of clutter. There are other options, such as Eclipse (with FDT Powerflasher) or obviously Adobe Flex Builder 3. I'll be concentrating mainly on Flashdevelop, as i've found this is simple and fairly straight forward to use.

Can Lightning Really Strike The Same Place Twice?

     It's true! Great minds can think alike! On the same day, in two different countries Kenneth Christensen and I were setting up actionscript blogs, nothing really strange in that. Both the blogs are about actionscript 3 programming, and we both visit the same flash forums. Still not much of a coincidence, until you know that we titled both our blogs the same! Spooky! And neither of us mentioned what we were doing anywhere! It must be a glitch in the matrix! Anyway, he's already posted some example flash code! Good stuff - check it out here flashcoding.blogspot.com/ (how's that for a free plug?).


Theme & Icons by N.Design Studio
Syndicate content