Looking good!

Posted by (twitter: @ddrkirbyisq)
April 19th, 2012 3:23 am

I’m not going to my dance event on Friday (only the one on Saturday), so I’ll have a bit more time.  We’re now about 1.5 days away from theme announcement!

I’ve finished my warmup game, TwinkleShooter, which went pretty well.  I’m definitely glad I took the time to do it, as I’ve learned a LOT of little detailed things about Flixel and Flash/AS3 that are really useful to know.  Here’s some of them that I noted down:

-There’s a bug in the main loop that causes frames to be dropped sometimes.  I forget the thread that this was noted in, but something about changing < and <= in an if statement fixes it and makes framerate much smoother.  When I pull the latest cutting edge Flixel repo I’ll have to check for this again.

-Do initialization of FlxStates in create, not the constructor of the state. One reason for this is that the camera doesn’t exist yet so any camera modifications don’t work in the constructor.

-Similarly, do initialization of FlxSprites in reset(), since the constructor isn’t called when you recycle an object.

-antialiasing issues.  It seems like Flixel is build upon the assumption that you’re always going to draw to integer coordinates and that you always want to clamp to integer coords for drawing.  However, when you rotate or scale sprites, that assumption breaks down because rotation and scaling (especially by not-nice numbers) looks kind of horrid unless you do some sort of interpolation.  So Flixel uses two different rendering paths, and chooses the “simple” copy-pixels-and-blit-blindly path for most normal rendering, EVEN if you have non-integral coords for your sprites.

The interesting thing is that there are multiple ways to hack around this depending on what you want.  For example, you can set your sprite’s rotation angle to 0.000001 and it’ll use the advanced render path, which means you’ll actually get subpixel effects instead of clamping.  Another way to do this is to simply modify the source of FlxSprite and have it always take the advanced render path.  I’m of the opinion that Flixel’s API should actually give you a way to do this, but for now knowing how to hack it is fine.

Also worth noting that setting antialias to true has no effect on whether or not pixel-clamping is used, but instead if pixel-clamping is NOT used, antialiasing tries to smooth things out more.  So that’s another option.

-memory management and recycling via flxgroups.  This is one of the cases where Flixel’s documentation isn’t totally clear because some of it isn’t quite there and some of it is incomplete.  Flixel Power Tools suffers from this at some points too, so it’s good to know these things beforehand so you don’t accidentally try to do things in an old-fashioned way.

-FlxWeapon seems nicer than it actually is. It’s a great idea but is kind of cumbersome, for multiple reasons, for example it’s not trivial to pass in your user-defined bullet class. I think the intent is that you use it to spawn a bunch of generic bullets and then use the FlxWeapon’s “group” to do your logic, but that raises the question of who owns the FlxWeapon’s group and who’s in charge of doing that and how does the management work. It doesn’t seem too clear to me, so unless I need the specific features that FlxWeapon offers maybe I’m better off not using it. It also expects you to package things into FlxSounds (and it can only play one instance of the sound at a time), so that’s another inconvenience. Setting the firing rate and target are easy with FlxWeapon though…so kind of a tradeoff.

-FlxSprites are NOT centered by default, so set offset.x = width/2 and offset.y = height/2 everywhere if you want that, otherwise the upper-left corner of your graphic will be the location of your sprite.

-LabChirp is like bfxr/sfxr but with more stuff! Pretty neat.

-Flash can’t embed oggs or wavs so you run into mp3 latency/seamless loop issues. For now I’m just running all of my mp3s through mp3loop.  There are other ways around this but I think this seems to be the easiest/most efficient one for now.

TODOs before Friday:

-Find a nice way to host an html page and embed an swf in it so that it’s centered nicely, instead of in the upper-left corner of the browser window.  Unfortunately google sites doesn’t allow you to embed flash content into its web pages, so this’ll have to be some kind of weird workaround, probably.

-Pull the latest versions of Flixel and Flixel Power Tools from github and check the following things:

1) did they change the main loop frame drop issue?

2) did FlxWeapon change?

3) does it still work with my project?

I should also mention I’m using Actuate for tweening.


edit: looks like the latest dev versions of flixel + power tools don’t really have anything notable that I’d miss, so I’m just going to stay on master for now.  So the only thing left is to find an easy way to embed nicely, which shouldn’t be too hard.

3 Responses to “Looking good!”

  1. Thief says:

    What’s the event/what kind of dance? I’m spending the *entire* of ludum dare 23 at a dance event myself, but should still have plenty of time as I’m only a tech not a dancer!

  2. It’s a social dance thing :)

  3. Thief says:

    Cool :)

    Theme announcement in a bit over 24 hours, good luck!

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]