Author Topic: Compilation of Flixel 3rd party Classes  (Read 11129 times)

zuperxtreme

  • Contributor
  • ****
  • Posts: 254
  • Karma: +0/-0
    • View Profile
    • Buddah
Compilation of Flixel 3rd party Classes
« on: Fri, Oct 15, 2010 »
Hey guys,

So I thought it would be a good idea to keep all the classes people have made into one thread that we can reference. These are all for Flixel 2+ and include a short excerpt/description of each:


  • FlxDialog
    Hey everyone, just thought I'd post my dialog class that I created for my games. It should be fairly non-intrusive for you to implement. It's also pretty bare bones, doing the absolute minimum as far as features. But feel free to add to it/make adjustments

  • FlxPathfinding
    I decided to use it for something. I have to say that I fell in love with its ease of use and power, so I decided to give something in return and I developed a class that allows to get the (hopefully) shortest path between two tiles in a tilemap. Of course it's mainly useful for topdown game, although it could be adapted also for platforms or side scrolling games.
    I used http://www.policyalmanac.org/games/aStarTutorial.htm as a reference for the algorithm and I borrowed some good implementative ideas from http://code.google.com/p/baseoneaslib/ 's AStar.

  • Cutscene class
    I'm not sure if adding cutscenes to Flixel games is an easy thing to do for most developers, but it was a bit of work for me. I looked around looking for tutorials with little luck, until finally I stumbled upon a solution that was able to work.

    To help those in my situation, I wrote a template class file to use when wanting to add cutscenes from external SWF files. I had trouble trying to write a class that you could construct, passing down the cutscene parameters as arguments. The only way I could get it to work for myself was to write a unique class for each cutscene.

  • FlxButton extended
    So I've been needing buttons with a different state when they're pushed.  I decided that rather than write around FlxButton and implement it differently, I would just alter FlxButton to support the normal state, the hover state, and a push state.

    There is now a third parameter to loadGraphic() and loadtext().  You still can specify null for the second parameter if you don't have a hover state.
    I have also altered it so that the push state is shown when the button is toggled on.

  • FlxCamera
    I just made a separate camera class for my project, given that internal Flixel's camera didn't have required functionality.

  • FlxBackdrop
    Here y'all go - an incredibly useful class for infinitely scrolling backdrops, written by Chevy Ray ages ago, back when I used flixel 1.3 or something. After a few modifications by me, it works fine in 2.*! ;D

  • FlxBitmapFont

    I've released my Bitmap Font class for Flixel 2. It allows you to easily use proper bitmap fonts in your games. Implementation is pretty easy, and the fonts extend an FlxSprite meaning you can throw them around, collide with them, etc. To change the text on display just use: fb.text = "new text"
  • FlxTimer

    Ok, I actually came up with something on my own. It was actually fairly simple, although it required some modification of a few Flixel classes.

    Updated Class: http://flashgamedojo.com/wiki/index.php?title=FlxTimer


  • FlxTilemap Slope

    Don't have a tutorial or anything on how to set this up, I hope you'll find it helpful. Also contains functions for loading OGMO map data.  Your tilemap needs to use this class.

    Basically your tile shapes in your map data have to coincide with the switch in getSlope() which is commented with descriptions of each tile's slope shape, and then in your state you would call:

    solveSlopeCollide(FlxTilemapExt, FlxGroup/FlxObject).

    Works with the quadtree's in 2, so collision against whatever works just fine.
    This is based on fefranca's solution, so kudos to him if he ever shows up again. Still buggy in the same way that the previous solution was with certain combinations, like slope running up to a vertical wall, but this is easily avoidable in designning your levels.
  • FlxCaveGenerator

    Working on my game, Between the Devil and the Deep Blue Sea, I implemented a really neat algorithm that generates caves quite elegantly. The description of the algorithm is described here. Just wanted to share the code with the community.


    The class FlxCaveGenerator can be used to generate a cave similar the image shown above. The caves are random each time you call the function.
  • FlxHitTest

    I give u pixel perfect overlap function ! With it you can test are 2 objects overlapping each other..
    Based on Tink's algorithm : http://www.tink.ws/blog/as-30-hittest/ .
    Thx Mirosabu for assistance!

    FEATURES :
    - works for any shape
    - works for any offset or origin
    - works perfectly even when objects are rotated
    - works for any scale
    - works for animated sprites
    - works for scrolling
  • FlxInputText

    An input text field that "fits in" with the Flixel workflow

    ...

    See how it looks!

    It has some cool features like forcing uppercase, text filtering with regexps, max length , colored border, colored background and such.

    For example, if I want a 3-uppercase-letters input textbox I only need to do this:

    Quote
    initialsInput = layer.add(new FlxInputText(X, Y, Width, Height, "", 0xffffff, null, 24)) as FlxInputText;
    initialsInput.setMaxLength(3);
    initialsInput.filterMode = FlxInputText.ONLY_ALPHA;
    initialsInput.forceUpperCase = true;

    //...

    var userInitials:String = initialsInput.getText();

    Latest updated: http://flixel.org/forums/index.php?topic=272.msg13575#msg13575
  • FlxTweaks
    Quote
    Basically link your game to a Google spreadsheet and dynamically change variables that'll affect the game at run-time
  • FlxSound Edit
    Quote
    This class deals with the padding MP3's have at the beginning of the file, effectively allowing you to loop MP3's
  • FlxXML
    So, after searching around a bit for a usable XML class and fumbling around with the as3 XML Loader stuff, I decided to create a wrapper class for the greensock XMLLoader to be used in flixel.
  • FlxMovieClip
    Turn MovieClip in to tilesets BitmapData, internally.

    Now something to note:
    1. I made this exclusively for my game, so I can't guarantee this would work out of the box (infact, it wouldn't). Take it as reference :D
    2. My code automatically generate a flipped version of the tilesets, this mainly because my game required it, but you might not needed it in most cases :)
  • Dynamic Pitch and Seamless Looping
    Here’s a rundown of what I’ve put together:

    1. Code that allows users to dynamically alter the pitch of a looping sound (like a race car’s engine rising in pitch as it goes faster).
    2. A document that explains how to get MP3s into your game (using SWC files) without that annoying silence at the front, so you can loop them seamlessly.
    3. Code that allows users to seamlessly loop MP3s that DO have silence if you can’t, or don’t want to, update your existing sounds to remove the silence.

    Here’s a link to the files:
    http://www.jasonseip.com/Flash/Dynamic_Pitch_and_Seamless_Looping.zip

    First, some credits: The dynamic pitch code was originally written by Kevin Luck. I adapted it to work with Flixel so the dynamic sounds could be managed the same as all your other game sounds. The SWC document was written by me after photonstorm offered some guidance. The seamless looping code was written by Max “Geti” Cahill.

    I created updated versions of FlxG and FlxSound from the v2.35 Flixel library…

    In FlxG: The “FlxG.play” function now has an additional (optional) parameter – a Boolean for if you want your sound to have dynamically updateable pitch. The Boolean defaults to false, so you don’t have to change any existing code, and can ignore the parameter for normal sounds. I didn’t integrate the dynamic pitch code with the seamless looping code, so there is a new call “FlxG.playLoopFix” if you want to loop MP3s that have silence at the front. That call has an added parameter “totalSamples” which is basically the length of the sound in seconds multiplied by the sample rate. The code is thoroughly documented, so you should have no problems understanding it.

    In FlxSound: There are several new functions for sound manipulation added to the end of the file. The “loadEmbedded” function has been updated for the dynamic pitch call, and a “loadEmbeddedLoopFix” function has been added for seamless looping, but you normally won’t need to touch these since your sound creation will take place through FlxG. The only important new code here that you’ll be interacting with is the “_playbackSpeed” variable for controlling dynamic pitch. That defaults to 1 – raising it makes the pitch go up, lowering it makes the pitch go down. To update it, simply add a line like this:

    <FlxSound object>.setPlaybackSpeed(<value>);

    I think that about covers everything.

    One tip/warning for using the dynamic pitch: if you instantiate your sound in the initial creation block of your class, you may hear a hiccup of silence as the game transitions from creating everything to actively updating. To solve this simply, I created a Boolean to track whether the sound was playing, then called the sound at the beginning of the “update” function for the class. It looks like this:

    if (!_soundPlaying) {
       _sndPlayer = FlxG.play(EngineSound, 1, true, true);
       _soundPlaying = true;
    }

    And there you go! Hopefully this will be of use. If you find any errors please let me know (I haven't come across any bugs so far, unless you count the above hiccup!).


Feel free to add your own! I think only 2.x should qualify, I doubt people are still using 1.x(that are just starting a project, and if so, use 2!).

Cheers.
« Last Edit: Wed, Jan 19, 2011 by zuperxtreme »
..."without order nothing exists, without chaos nothing evolves"... 
Zoklet.net

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Compilation of Flixel custom(3rd party?) Classes
« Reply #1 on: Fri, Oct 15, 2010 »
Really good idea.
I wanted to see the Slopes one in here. I got the impression it was added into the main version of Flixel. Not sure though, which is why it would be good to get some extra information.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

Billy

  • Active Member
  • ***
  • Posts: 159
  • Karma: +0/-0
  • Herper of Derps
    • View Profile
    • billy.wenge-murphy.com
Re: Compilation of Flixel custom(3rd party?) Classes
« Reply #2 on: Fri, Oct 15, 2010 »
Don't forget FlxTimer! It's a few threads down

zuperxtreme

  • Contributor
  • ****
  • Posts: 254
  • Karma: +0/-0
    • View Profile
    • Buddah
Re: Compilation of Flixel custom(3rd party?) Classes
« Reply #3 on: Sat, Oct 16, 2010 »
There we go, added FlxTimer and FlxTilemap Slopes. :D

EDIT: Added FlxCaveGenerator.
« Last Edit: Sat, Oct 16, 2010 by zuperxtreme »
..."without order nothing exists, without chaos nothing evolves"... 
Zoklet.net

OmegaStorm

  • Member
  • **
  • Posts: 36
  • Karma: +0/-0
    • View Profile
    • OmegaStorm Productions
Re: Compilation of Flixel custom(3rd party?) Classes
« Reply #4 on: Sat, Oct 16, 2010 »
Good to have all these in one place. This should totally be a sticky.

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Compilation of Flixel custom(3rd party?) Classes
« Reply #5 on: Sat, Oct 16, 2010 »
Good to have all these in one place. This should totally be a sticky.

Agreed. This is a fantastic resource.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

hanuman

  • Member
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
    • Physics Games
Re: Compilation of Flixel 3rd party Classes
« Reply #6 on: Wed, Oct 20, 2010 »
Amazing idea. Thanks for gathering it all in one place.

DelishusCake

  • délicieux gâteau
  • Member
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Compilation of Flixel 3rd party Classes
« Reply #7 on: Wed, Nov 3, 2010 »
Don't  forget FlxInputText:
http://flixel.org/forums/index.php?topic=272.0
The v2.x versions are a few post down.

zuperxtreme

  • Contributor
  • ****
  • Posts: 254
  • Karma: +0/-0
    • View Profile
    • Buddah
Re: Compilation of Flixel 3rd party Classes
« Reply #8 on: Wed, Nov 3, 2010 »
Added, thanks, hadn't seen it. :)
..."without order nothing exists, without chaos nothing evolves"... 
Zoklet.net

SysOp

  • Member
  • **
  • Posts: 53
  • Karma: +0/-0
    • View Profile
    • check my kick ass half-life mod!
Re: Compilation of Flixel 3rd party Classes
« Reply #9 on: Wed, Nov 3, 2010 »
Oh, sounds excellent mate! Some mod should stick this topic!
"Hope is not a dream, but a way of making dreams become reality"

SeiferTim

  • Contributor
  • ****
  • Posts: 253
  • Karma: +0/-0
    • View Profile
    • Tim's World
Re: Compilation of Flixel 3rd party Classes
« Reply #10 on: Thu, Nov 4, 2010 »
I would definitely consider putting this list on the Flash Game Dojo - maybe make a category for them? I think i started messing with that when I put the Displacement code (Which should be in your list ;) ) but didn't finish...

Edit: ...actually, if you don't mind, I'll go ahead and start working on it over there :P come and help if you want!
http://flashgamedojo.com/wiki/index.php?title=Category:Add_Ins
« Last Edit: Thu, Nov 4, 2010 by SeiferTim »

zuperxtreme

  • Contributor
  • ****
  • Posts: 254
  • Karma: +0/-0
    • View Profile
    • Buddah
Re: Compilation of Flixel 3rd party Classes
« Reply #11 on: Thu, Nov 4, 2010 »
Sure man, feel free to add it. I'm a bit busy now, but when I get home if you haven't finished I'll finish up. :)

Cheers.
..."without order nothing exists, without chaos nothing evolves"... 
Zoklet.net

Kronoshifter

  • Member
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Compilation of Flixel 3rd party Classes
« Reply #12 on: Wed, Nov 24, 2010 »
This is sweet seeing my class in a list like this. Just for future reference, the FlxTimer in the forums here is way out of date. For the most up to date version check out the page on the Flash Game Dojo.
http://flashgamedojo.com/wiki/index.php?title=FlxTimer
Be warned though, it breaks the ability to add parameters to the listener, unless there's some way to register a set of parameters to a listener with AS3 Signals. Also, make sure you have AS3 Signals or it won't work.

Plaski

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Compilation of Flixel 3rd party Classes
« Reply #13 on: Mon, Dec 6, 2010 »
great thread, more please.

zuperxtreme

  • Contributor
  • ****
  • Posts: 254
  • Karma: +0/-0
    • View Profile
    • Buddah
Re: Compilation of Flixel 3rd party Classes
« Reply #14 on: Tue, Dec 7, 2010 »
Added 3 more. You guys are welcome to submit your own! :)
..."without order nothing exists, without chaos nothing evolves"... 
Zoklet.net

zuperxtreme

  • Contributor
  • ****
  • Posts: 254
  • Karma: +0/-0
    • View Profile
    • Buddah
..."without order nothing exists, without chaos nothing evolves"... 
Zoklet.net

eduardonunesp

  • Member
  • **
  • Posts: 55
  • Karma: +0/-0
    • View Profile
    • Blog Dream Escape.
Re: Compilation of Flixel 3rd party Classes
« Reply #16 on: Wed, Feb 2, 2011 »
O cool i made a class for a flixel too, not so wonderful, but help to recycle the sprites over the time.

And i made a version o FlxTimer without dispatch,
Code: [Select]
package org.flixel {
   
/**
* Stores a rectangle.
*/
    public class FlxRecycler extends FlxGroup
    {
/**
* @default 0
*/
        protected var _index:uint = 0;

        /**
         * @default 0
         */
        protected var _max:uint = 0

/**
* Instantiate a new recycler.
*/
        public function FlxRecycler(Max:uint=0)
        {
            _max = Max;
            super();
        }

override public function add(Object:FlxObject,ShareScroll:Boolean=false):FlxObject
        {
            if(members.length <= _max || _max == 0)
            {
                super.add(Object, ShareScroll);
            }

            return Object;
        }

public function isMax():Boolean
{
return (_max == members.length);
}

/**
* Returns the object and proced the recycling
         *
* @param X The X-coordinate of the point in space.
* @param Y The Y-coordinate of the point in space.
*/
        public function getObject(X:Number,Y:Number):FlxObject
        {
            var s:FlxObject = members[_index];
            s.reset(X, Y);
s.health = 1;
            _index++;

            // if the index equal recycler size then let's zero the index
            if(_index >= members.length - 1)
                _index = 0;
            return s;
        }
    }
}


Kronoshifter

  • Member
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Compilation of Flixel 3rd party Classes
« Reply #17 on: Thu, Mar 3, 2011 »
Quote
And i made a version o FlxTimer without dispatch

I would very much like to see this. What do you mean without dispatch?

eduardonunesp

  • Member
  • **
  • Posts: 55
  • Karma: +0/-0
    • View Profile
    • Blog Dream Escape.
Re: Compilation of Flixel 3rd party Classes
« Reply #18 on: Fri, Mar 4, 2011 »
Sorry by the "tabs" in source, the code is quite simple

https://github.com/eduardonunesp/flixel/blob/dev/org/flixel/FlxTimer.as

Kronoshifter

  • Member
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Compilation of Flixel 3rd party Classes
« Reply #19 on: Sat, Mar 5, 2011 »
Ah. I see what you mean now. There's a reason I didn't use just one callback. Say, for instance, you wanted more than one function to fire when the timer dispatches. If you only use one callback, there's no way to do that. I do agree with your destroy() function though. I can't believe I didn't think to put that in there.