Flixel Forums

development => help => Topic started by: photonstorm on Sat, Feb 19, 2011

Title: Flash Game Dev Tips
Post by: photonstorm on Sat, Feb 19, 2011
I've started writing a series of Flash Game Dev Tips. They provide solutions for common flixel (and general flash / game dev) related issues. Some as a result of threads I read here, others from my own game making.

Here are the current articles:

Tips

Tip #1 Creating a cross-game communications structure (http://www.photonstorm.com/archives/1136/flash-game-dev-tip-1-creating-a-cross-game-communications-structure)

Tip #2 - Flixel and TweenMax pausing together (http://www.photonstorm.com/archives/1156/flash-game-dev-tip-2-flixel-and-tweenmax-pausing-together)

Tip #3 - Bullet Manager, Part 1 (http://www.photonstorm.com/archives/1164/flash-game-dev-tip-3-bullet-manager-part-1)

Tip #4 - Bullet Manager, Part 2 (http://www.photonstorm.com/archives/1180/flash-game-dev-tip-4-bullet-manager-part-2) (building a shmup)

Tip #5 - Configure your Games in Real-Time (http://www.photonstorm.com/archives/1187/flash-game-dev-tip-5-configure-your-games-in-real-time)

Tip #6 - Setting-up FlashDevelop and Flixel for the first time (http://www.photonstorm.com/archives/1200/flash-game-dev-tip-6-setting-up-flashdevelop-and-flixel-for-the-first-time)

Tip #7 - Introducing the Flixel Power Tools (http://www.photonstorm.com/archives/1233/flash-game-dev-tip-7-introducing-the-flixel-power-tools)

Tip #8 - Building a shoot-em-up Part 3, Return Fire (http://www.photonstorm.com/archives/1191/flash-game-dev-tip-8-building-a-shoot-em-up-part-3-return-fire)

Tip #9 - Dealing with a lack of motivation to finish your game (http://www.photonstorm.com/archives/1307/flash-game-dev-tip-9-dealing-with-a-lack-of-motivation)

Tip #10 - Flixels Internal Structure and Performance Tips (http://www.photonstorm.com/archives/1464/flash-game-dev-tip-10-flixel-2-5-internal-structure-and-performance-tips)

Tip #11 - The Flixel Display List Explained (http://www.photonstorm.com/archives/1530/flash-game-dev-tip-11-the-flixel-display-list-explained)

Tip #12 - Building a Retro Platform Game in Flixel, Part 1 (http://www.photonstorm.com/archives/2247/flash-game-dev-tip-12-building-a-retro-platform-game-in-flixel-part-1)

Tip #13 - Building a Retro Platform Game in Flixel, Part 2 (http://www.photonstorm.com/archives/2264/flash-game-dev-tip-13-building-a-retro-platform-game-in-flixel-part-2)

Tip #14 - How to create a Flixel plugin (with tinted mirrored camera example!) (http://www.photonstorm.com/archives/2540/flash-game-dev-tip-14-how-to-create-a-flixel-plugin)

Tip #15 - Collectable Particles in Flixel (with demo and source) (http://www.photonstorm.com/archives/2642/flash-game-dev-tip-15-collectable-particles)

I'll keep this post updated with the list of articles. But if you would like to request an article then please do so!
Title: Re: Flash Game Dev Tips
Post by: tomii on Thu, Feb 24, 2011
Great articles, I just read them both.
In #1, What is the purpose of having 'public static var stage:Stage;' in your Registry?

Guide request: What is the best way to show an impact animation when, say, a grenade or other projectile hit something in the game - and you want the impact animation to be bigger than the projectile itself?
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Fri, Feb 25, 2011
I always like to have a direct reference to Stage available without relying on the game being part of the display list, so it's just a short-cut to that. Allows you to get to stuff like loaderInfo params, events, etc.
Title: Re: Flash Game Dev Tips
Post by: alteveer on Fri, Mar 4, 2011
What about FlxG.stage?
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Sat, Mar 5, 2011
No use, it's only available when the game is running. The reference I have can be (and is) used outside of the flixel game itself.
Title: Re: Flash Game Dev Tips
Post by: alteveer on Sun, Mar 6, 2011
Quote
No use, it's only available when the game is running. The reference I have can be (and is) used outside of the flixel game itself.

What for?
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Sun, Mar 6, 2011
Ok, for example the pause screen in my last game Cat Astro Phi - that isn't a flixel pause screen, because the game was in zoom x2 but the pause needed x1 scale and mouse interactions without the game capturing them. So I used an external set of functions (which needed access to the stage for listeners) to do this.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: knivel on Sun, Apr 3, 2011
Hey man, I just started playing around with the Power Tools and I've found an issue with the FlxMath.rand() method. I was passing it min and max values of 3 and 10 and getting back 11's and 12's.

When I dug into the code, I found this:

Code: [Select]
return min + (Math.random() * max);
which I'm guessing should be this:

Code: [Select]
return min + (Math.random() * (max - min));
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Sun, Apr 3, 2011
Well spotted. Fixed and committed.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: RozzleDozzle on Sun, Apr 3, 2011
I came to say thanks for the first tip...I ended up using a registry like the one suggested and it turned out perfect for my project. Then I saw your new Flixel Power Tools.

Holy smokes, they are great! I am sure many of us have used this random number function (http://scriptplayground.com/tutorials/as/Generate-random-number-in-ActionScript-3/ (http://scriptplayground.com/tutorials/as/Generate-random-number-in-ActionScript-3/)), but now we have a built in one! And I was definitely planning on using a timer in my current  project, so this came out just in time!

Quick question, just out of curiosity: Are some of the functions in FlxVelocity (such as movetowardsobject) meant to tween, or maybe even replace other tween libraries? Just a curious thought...or maybe I don't fully understand tweening!
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Mon, Apr 4, 2011
Glad you're enjoying the library, loads more to add yet! As for FlxVelocity it's not really meant to replace a tweening library such as greensock, it's really more to help move sprites around via velocity (rather than modifying x/y values directly, which stops them from colliding properly, etc).

I guess the end result may overlap a little with what the likes of TweenMax can do (having said that, I've never tried tweening flixel velocity values!), but if you don't need the full weight of a tween lib sitting around then it made sense (to me at least!) to keep it light and flixel specific.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: initials on Mon, Apr 4, 2011
FlxHealthBar is a fantastic idea. Thanks for adding that, can't wait to start a new game with all these tools.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: XanderXevious on Sat, Apr 16, 2011
Strange little bug here.

I'm using Flex 3 and tried the latest PowerTools test suite with Flixel 2.5 and Flash Develop. I got this error throughout the code when building the project:

Code: [Select]
Error: Incompatible default value of type Number where int is expected.
It was refering to every instance where there would be something like this:

Code: [Select]
highestColor:int = 0xffF4F4F4
However, changing every one of these to a uint removed the errors and the suite ran perfectly.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Sat, Apr 16, 2011
Very odd. I compile against Flex 4 (and 4.1) and don't get this warning. I always code in Strict mode with Warnings displayed too. Will see if I can test them out against flex 3.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: Jimbo on Wed, Apr 20, 2011
I can't tell if this is due to FlxVelocity or FlashDevelop, but even though everything looks above-board in the code window, when I try to compile I get this error:

col: 16 Error: Access of undefined property FlxVelocity.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: mightiest_hero on Wed, Apr 20, 2011
you must copy Flixel Power Tools from photon storm and import it

if you using FlxCollision.pixelPerfectCheck() function
you must change in FlxSprite.as
from
protected var _framePixels:BitmapData;
to
public var _framePixels:BitmapData;
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: Jimbo on Wed, Apr 20, 2011
It's imported and the public variables declared, but

AimAngle = FlxVelocity.angleBetweenMouse(Player, true);

Is the code that initially set it off.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Wed, Apr 20, 2011
Does your code compile fine if you comment out that line?

Have you copied the power tools into your src folder (or linked them from the Global Class setting in the Project properties) ?
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: Jimbo on Wed, Apr 20, 2011
Does your code compile fine if you comment out that line?

Have you copied the power tools into your src folder (or linked them from the Global Class setting in the Project properties) ?

Yes on both counts. FlashDevelop even supplies me with code hints when I call the function, indicating that it recognizes the class is imported.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Wed, Apr 20, 2011
Do all of the power tools do this, or just FlxVelocity? For example can you compile and run the Test Suite ok?
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: Jimbo on Wed, Apr 20, 2011
The Test Suite works fine with the version of Flixel included in the download (Flixel v2.5 Patch 1.0), but for when I use that version in any other project it causes compiling errors in pretty much every instance a Flx class references FlxCamera, saying various methods in that class are undefined.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Wed, Apr 20, 2011
Hmm it still sounds like a structural issue to me (project structure, mixture of versions).

Let me try the test suite when I get back with the latest dev branch of flixel (although I'm sure the version in svn was updated very recently.. although not in the zip file).

But if the Test Suite works with flixel 2.5p1, then there's no reason why copying that version of flixel to a new fresh project, and just coding, shouldn't work too?
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Fri, Apr 29, 2011
Forgot to mention this:

To get Flixel Power Tools to compile properly I had to change all the hexadecimal numbers (0xXXXXXX) from int to Number. It was giving me an error because it was an int and not a number...
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: choifish on Fri, Apr 29, 2011
I had the same problem, but I think I solved it by updating to the newest version of Flex.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Fri, Apr 29, 2011
This must be Flex specific as I get no such compiler errors from 4.0 or 4.1 - are you still on an old release? v3?
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: XanderXevious on Fri, Apr 29, 2011
It just needs to be a uint, not a Number.

It's incompatible with Flex 3 according to these docs:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/uint.html (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/uint.html)
Quote
the number 0xFFFFFFFF, which represents the color value white with an alpha value of 255, can't be represented using the int data type because it is not within the valid range of the int values.

It might be worth changing those to a uint so it's compatible with Flex 3, assuming that doesn't break anything with Flex 4
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Sun, May 1, 2011
Ok, the version in svn now uses uints for all colour values, so should be flex 3 savvy. Note - only in svn, this won't make it to the download version until v1.5 is released.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Thu, May 5, 2011
How do you use Flixel power tools in 2.5 these days?
I don't really understand how plug-ins work.

Thanks,
Mint
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Thu, May 5, 2011
It's even easier, just copy the photonstorm folder into org.flixel.plugins !

The page on my site describes the process clearly.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Thu, May 5, 2011
Sorry photonstorm I can't seem to find the page the describes the process clearly. I put the plugin into org.flixel.plugins but I still don't know how to access the classes  :-\
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Thu, May 5, 2011
An overview of what all the classes do is here:

http://www.photonstorm.com/flixel-power-tools

But the easiest way to learn is to open up the Test Suite and look at the source files - there are loads of them, one or more for each plugin. If you want to learn how to use the scroll zones, then look at the 4 scroll zone test source files, they are all documented, as are the classes themselves.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Fri, May 6, 2011
I totally forgot about the test suite, sorry.
Now it's up an running, I just had to import org.flixel.photonstorm.*
 :)
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Wed, May 11, 2011
Last night I updated the Flixel Power Tools significantly. There are now a bunch of new classes, including a Special FX class which uses its own plugin system to keep things clean.

I also wrote a 6 page Getting Started guide.

And the whole project has now moved to github, with a lot friendly structure for beginners, and quicker to get started. The Test Suite was also updated with lots of new demos and a small re-jig of the design.

Full details here:

http://www.photonstorm.com/archives/1332/flixel-power-tools-v1-5-a-monster-of-an-update
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: St.Penguin on Wed, May 11, 2011
Photon, thanks for your continued work on the power tools, a huge help to beginners and a time-saver to many!
That said, gladly updating now.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Tue, May 17, 2011
v1.6 is officially released! Includes an extremely handy new class called FlxControl, some bug fixes and a new Special FX. Full details here:

http://www.photonstorm.com/archives/1338/flixel-power-tools-v1-6-released-including-flxcontrol
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Thu, May 19, 2011
Hey photonstorm I have a suggestion.
Can you turn flxhealthbar just into FlxBar?

Where instead of just following a sprite's health, we send in
what value we want to the bar to follow. For example if I had a public variable
powerUP:int = 5; I should be able to do

public function FlxHealthBar(Parent:Flxsprite, FollowNumber:Number, Width:int, Height:int, Min:uint = 0, Max:uint = 100, Border:Boolean = false):void

If we want to do health we can just call FlxObject.health()

What do you think?
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Thu, May 19, 2011
That's not a bad idea actually - then you could use it for progress bars, etc too. You'd also have to set the min/max limits that value can ever be, otherwise it'd be impossible for it to know how far along it was.

I'll add it to the list. Am just finishing Extended Sprites first.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Thu, May 19, 2011
Awesome, can't wait for the new update  :)
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Mon, May 23, 2011
I have another idea to add on to the FlxBar idea I had earlier (if you haven't already thought of this). When creating the FlxBar it would be nice if the user is able to add a callback function when the bar is empty and/or when the bar is full. Thanks Photon.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Tue, May 24, 2011
Sure that should be pretty simple to add, have added it to the list.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: janrey10 on Wed, May 25, 2011
Wow! I saw the steps and it seems great and i am going to try it.

Hope it will work.

^_^
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Wed, May 25, 2011
Lol, back again with another suggestion photonstorm.
I was trying to hack this, but didn't succeed.

Right now I have a bunch of enemies with healthbars, so basically I created 100 health bars and want to recycle them instead of newing the healthbars on the fly.

Code: [Select]
for (var i:int = 1; i <= 100; i++)
{
healthbars.add(new FlxHealthBar(new FlxSprite(0,0,null), 10, 1, 0, 10, false));
}

However I realized there is no function where I can set a new parent.
So I created one that does parent = Parent.
Then for my enemies I did:
Code: [Select]
(Registry.healthbars.getFirstAvailable() as FlxHealthBar).setNewParent(this);
But ended up getting an error (I think null reference).
What do you think?

Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Wed, May 25, 2011
No worries, I've added this into the new FlxBar class. FlxBar replaces FlxHealthBar and can be hooked to any class/object and read any value from it. So FlxSprite.health, FlxG.mouse.screenX, etc! Or any class you create. There are callbacks for when the bar hits full or empty. You can also set the percentage fill of the bar directly, and it can run in any direction - left to right, right to left, top to bottom, inside out, outside in, etc. Just fixing-up an issue (with the way flixel plugins update vs. FlxSprites) and it can go live.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Wed, May 25, 2011
Awesome, you rock photon! :D
No worries, I've added this into the new FlxBar class. FlxBar replaces FlxHealthBar and can be hooked to any class/object and read any value from it. So FlxSprite.health, FlxG.mouse.screenX, etc! Or any class you create. There are callbacks for when the bar hits full or empty. You can also set the percentage fill of the bar directly, and it can run in any direction - left to right, right to left, top to bottom, inside out, outside in, etc. Just fixing-up an issue (with the way flixel plugins update vs. FlxSprites) and it can go live.
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: paala on Wed, May 25, 2011
Is this version of power tools compatible with flixel 2.43. If not, where can I download older versions?
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Thu, May 26, 2011
paala - no, it hasn't been compatible with 2.43 for several versions now. You can find the old releases archived at http://code.google.com/p/flash-game-dev-tips/
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: paala on Thu, May 26, 2011
Thank you so much. Your work is so great!
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: foosety on Wed, Jun 1, 2011
How is the development for FlxBar coming along?
I'm really eager to put it to use  :-*
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: photonstorm on Wed, Jun 1, 2011
Finished - just doing new Test Cases for it :)
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: VictorGrunn on Wed, Jun 1, 2011
Just a quick question.

I recall reading than an updated version of the great Return Fire program is coming. One thing I'm wondering is, is the change in Emitters between the last version of this tutorial and the 2.5+ Flixel version that major?

I'm using the tutorial to great effect now, and that's the one thing that has me stuck. As-is, the on-enemy-impact particles are not firing when explodeBlock is called.

The code in question:

Quote
      public function Fx()
      {
         super();         
         
         pixels = new FlxGroup();         
         
         //   Here we create an FlxGroup containing 40 FlxEmitters, all the same, used when the aliens are shot/explode
         for (var i:int = 0; i < 400; i++)
         {
            var tempPixel:FlxEmitter = new FlxEmitter();
            tempPixel.setSize(8, 8);
            tempPixel.gravity = 200;
            tempPixel.setXSpeed(-50, 50);
            tempPixel.setYSpeed( -30, -60);
            tempPixel.setRotation(0, 0);   // VITAL!!!
            tempPixel.makeParticles(Pixel, 4, 0, true, 0)
                                pixels.add(tempPixel);
         }
         

         add(pixels);

      }


and

Quote
      public function explodeBlock(ax:int, ay:int):void
      {
         var pixel:FlxEmitter = FlxEmitter(pixels.getFirstAvailable());
         if (pixel)
         {
            pixel.x = ax;
            pixel.y = ay;
            pixel.start(true, 1);
         }         
      }
Title: Re: Flash Game Dev Tips + Flixel Power Tools
Post by: Manji on Tue, Jun 7, 2011
Hi,

is there any way to change the Button Border color ?
Title: Re: Flash Game Dev Tips
Post by: maxbadger on Fri, Jun 24, 2011
VictorGrunn:

I don't know if you've solved this by now, but I was having the same problem.
In the top code chunk add:
Code: [Select]
  tempPixel.exists = false;
Otherwise getFirstAvailable will find that each one already exists, so it can't place 'em.
Title: Re: Flash Game Dev Tips
Post by: jyrde on Fri, Jul 15, 2011
maxbadger:

Did you have any trouble with the emitters not being recycled? What I mean is, by setting the tempPixel.exists = false I can now use all the 40 emitters only once and after they have been used there are no more particle effects.

Debugging shows that the particles are never dying (exists, alive, active = true) and their coordinates keep on growing. So the getFirstAvailable isn't returning a emitter to use. Been trying to figure out what I am doing wrong but so far no luck. In the end I just created an index variable to get each of the emitters from the FlxGroup one after the other but I would still like to understand why this is happening?

Any ideas anyone? Using Flixel 2.55 and FlashDevelop 3.3.2.

Also this is my first post to the forums, hi everyone :). Thanks for the great tutorials.
Title: Re: Flash Game Dev Tips
Post by: grexbo on Tue, Jul 19, 2011
to all:
Hello all,  I am also beginning to learn flixel via these tutorials and tips. Thanks for all who contributed.

jyrde:
Having stayed on same situation as you on new FlxEmitter (2.5+) problem before, and again today I think this may help:

First make sure to set a maxsize for particle group:
Code: [Select]

public function Fx()
{
super();
                        //giving 20 as maxsize for group
pixels = new FlxGroup(20);
                       
                        //filing maximum number of members
                        //to make sure recycle does not return empty members
                        for (var i:int = 0; i < 20; i++)
                        ...
                 }

On explodeblock use recycle function to get next emitter
Code: [Select]
public function explodeBlock(ax:int, ay:int):void
{
//var pixel:FlxEmitter = FlxEmitter(pixels.getFirstAvailable());
//using recycle to get first available flxemitter members are never tagged
//exists= false so getFirstAvailable seems useless

var pixel:FlxEmitter = pixels.recycle(FlxEmitter) as FlxEmitter; 

if (pixel)
{
pixel.x = ax;
pixel.y = ay;
//pixel.start(true);
//using 2 secs for particle lifespan
//frequency has no effect for explosion
pixel.start(true, 2, 0, 0);
}
}


Note that I am sure and tested maxsize for FlxGroup is not increased, yet unsure if this effects performance.

Another alternative is set all members exits= false on null object return, but I see above code is better.

Title: Re: Flash Game Dev Tips
Post by: grexbo on Thu, Jul 21, 2011
For those having trouble with Tip 8.

I have added Flixel 2.5 (and Photonstorm for 2.5) changes PhotonStorms Tip#8 Return Fire tutorial.
Available at :
https://github.com/grexbo/FlixelTutorials (https://github.com/grexbo/FlixelTutorials)

Hope Photonstorm does not mind.

Note that you have to manually add Flixel and Powertools sources to your project.
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Thu, Jul 21, 2011
Nice one grexbo - thanks :)

I posted Tip 10 (http://www.photonstorm.com/archives/1464/flash-game-dev-tip-10-flixel-2-5-internal-structure-and-performance-tips) today as well, which may be of some interest to those wanting to know how Flixel is doing stuff internally.
Title: Re: Flash Game Dev Tips
Post by: NateTheGreatt on Sat, Jul 30, 2011
You are beauty. How do I buy you a coffee??
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Sat, Jul 30, 2011
Haha I like that your reply said how do you donate, edited to a mere coffee ;)

(just messing, I don't need donations or coffee, just like to see people make/learn stuff)
Title: Re: Flash Game Dev Tips
Post by: NateTheGreatt on Sun, Jul 31, 2011
Haha I like that your reply said how do you donate, edited to a mere coffee ;)

(just messing, I don't need donations or coffee, just like to see people make/learn stuff)

C: You are a good person.

I WILL buy you a coffee someday...
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Fri, Aug 19, 2011
For those who subscribe to notifications on this thread I just wanted to say that Tip 11 - The Flixel Display List was posted a couple of days ago.

Tip #11 - The Flixel Display List Explained (http://www.photonstorm.com/archives/1530/flash-game-dev-tip-11-the-flixel-display-list-explained)
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Sun, Sep 18, 2011
And here's Tip #12 - Building a Retro Platform Game in Flixel, Part 1 (http://www.photonstorm.com/archives/2247/flash-game-dev-tip-12-building-a-retro-platform-game-in-flixel-part-1)
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Wed, Sep 21, 2011
And here's Part 2 to the above article: Building a Retro Platform Game in Flixel, Part 2 (http://www.photonstorm.com/archives/2264/flash-game-dev-tip-13-building-a-retro-platform-game-in-flixel-part-2)
Title: Re: Flash Game Dev Tips
Post by: test84 on Wed, Sep 21, 2011
And here's Part 2 to the above article: Building a Retro Platform Game in Flixel, Part 2 (http://www.photonstorm.com/archives/2264/flash-game-dev-tip-13-building-a-retro-platform-game-in-flixel-part-2)

Thanks! They are invaluable.
Title: Re: Flash Game Dev Tips
Post by: Kimikaze-N00B on Wed, Oct 19, 2011
My way of getting confidence back to making a game: Make a blank room,like a new house.Set it up so your friend can join,and start chatting about what to add in the room.A bed,table,lamp,chairs and a bookshelf.Then we add doors,and doors,and doors untill we have a game.I don't know what game I'm gonna make untill it's done,most of the time
Title: Re: Flash Game Dev Tips
Post by: Crowley on Sat, Oct 22, 2011
I've noticed we've gone through two archetypes of games, being a shoot 'em up and a sidescrolling platforming adventure game.

What about a top down RPG game? Preferably something that takes advantage of FlxWeapon, as I've seen a good deal of people over the forums having trouble with that...
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Tue, Nov 1, 2011
Here's Tip #14 - How to create a Flixel plugin (with tinted mirrored camera example!) (http://www.photonstorm.com/archives/2540/flash-game-dev-tip-14-how-to-create-a-flixel-plugin)
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Wed, Nov 30, 2011
Tip #15 is out - Collectable Particles in Flixel (http://www.photonstorm.com/archives/2642/flash-game-dev-tip-15-collectable-particles)
Title: Re: Flash Game Dev Tips
Post by: test84 on Thu, Dec 1, 2011
It's fantastic, thanks!
Title: Re: Flash Game Dev Tips
Post by: Alextfish on Thu, Dec 1, 2011
Yay, this is indeed useful. Many thanks!
Title: Re: Flash Game Dev Tips
Post by: test84 on Thu, Dec 1, 2011
I have a question: I was reading your coin collision code to learn more from how you code and I wondered about several places that you overrided a method but just called the super version of it, is there anything to do with this?
i.e. in coin.as:
Code: [Select]
override public function update():void
{
super.update();
}

or in PlaySate:      
Code: [Select]
override public function destroy():void
{
super.destroy();
}
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Thu, Dec 1, 2011
I just do it as standard because for nearly everything I build my update/destroy methods are far more complex than the above. You don't technically need them in this specific example.
Title: Re: Flash Game Dev Tips
Post by: test84 on Thu, Dec 1, 2011
I just do it as standard because for nearly everything I build my update/destroy methods are far more complex than the above. You don't technically need them in this specific example.

Tnx.
While we are at it, would you name situations where you would need a destroy method? I know about C/C++'s case but not about AS3.
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Thu, Dec 1, 2011
When you want to do some house-keeping, i.e. the class has maybe created its own local bitmapDatas that need nuking, or event listeners, etc.
Title: Re: Flash Game Dev Tips
Post by: Jeff on Sat, Jul 28, 2012
In general, do you people often have problems with performance? What are some pitfalls that can make noticeable setbacks to performance? This is generally a subject I'm timid about, since if performance declines, it may be hard to figure out what to do about it.

With what I've tested now, it seems like having extra FlxCameras can reduce performance significantly. In general, this is understandable, if you have lots of stuff within the camera's viewing range, but if the camera doesn't see anything, should it then decrease performance? And if you have a camera that basically just shows text, should that decrease performance? By default I only used two cameras, but I added two more to hide things. It worked fine, but seemed to damage performance. Any comments about that? Should one seriously avoid having extra FlxCameras or can you do something to avoid this kind performance decline?
Title: Re: Flash Game Dev Tips
Post by: zaphod on Sat, Jul 28, 2012
@Jeff: extra cameras means extra checks for visibility (includes square root calculation) also.
If you want to use extra camera for showing just a single text then you need to exclude that camera from .cameras array property of all other sprites. For example:

Code: [Select]
var sprite:FlxSprite;
for each (basic:FlxBasic in FlxG._state.members)
{
    if (basic is FlxSprite)
    {
        sprite = FlxSprite(basic);
        sprite.cameras = [camera1, camera2];
    }
}

It will reduce number of visibility checks for your "text" camera. Plus you can set:
Code: [Select]
yourtext.cameras = [textCamera];And this text will never appear on other camera's view
Title: Re: Flash Game Dev Tips
Post by: Jeff on Tue, Aug 21, 2012
@Jeff: extra cameras means extra checks for visibility (includes square root calculation) also.
If you want to use extra camera for showing just a single text then you need to exclude that camera from .cameras array property of all other sprites. For example:

Code: [Select]
var sprite:FlxSprite;
for each (basic:FlxBasic in FlxG._state.members)
{
    if (basic is FlxSprite)
    {
        sprite = FlxSprite(basic);
        sprite.cameras = [camera1, camera2];
    }
}

It will reduce number of visibility checks for your "text" camera. Plus you can set:
Code: [Select]
yourtext.cameras = [textCamera];And this text will never appear on other camera's view

This was a very slow answer from my side, but thanks! That should be very useful! :) I would have thought it's the cameras where it's defined what they render, not objects defining by which cameras they are rendered. I'll probably try that out at some point. Then I could do the hiding and even make it faster than originally by selecting what the two absolutely necessary cameras see! Hmm... in fact this could even be used in a more creative way, not just for performance issues.  8)

I would have another general question. Do people usually just use the "kill" function when getting rid of objects? Doesn't that often mean wasting resources unnecessarily? I mean kill only kind of "disables" the object, it doesn't really remove it, right? What's the point of having the objects around, even if they will never be used again? Similarly, I'm wondering what's the purpose of the "exists" flag? I find the name misleading since when you're able to call myObject it does exist, even if it's "exists" flag were false. Moreover, if setting it false just disables both updating and drawing, you can do the same thing by using active and visible.
Title: Re: Flash Game Dev Tips
Post by: sriram on Sat, Sep 29, 2012
The Retro Platform Game tips was highly informative and inspiring ! I've been looking into making a Platformer game and this really helped me get a start (still checking out the code,experimenting)

Any chance of sharing tips on dealing with an auto runner Platformer ? Both as in Canabalt ,and like the HTML5 nutmeg game on your site, that would be great! :)
Title: Re: Flash Game Dev Tips
Post by: Gama11 on Mon, Nov 5, 2012
The Retro Platform Game tips was highly informative and inspiring ! I've been looking into making a Platformer game and this really helped me get a start (still checking out the code,experimenting)

Any chance of sharing tips on dealing with an auto runner Platformer ? Both as in Canabalt ,and like the HTML5 nutmeg game on your site, that would be great! :)

Canabalt for iOS is actually on github (https://github.com/ericjohnson/canabalt-ios), which might help, because it uses the iOS port of flixel.
Title: Re: Flash Game Dev Tips
Post by: novellof on Mon, Nov 12, 2012
Hey great post but on tip #1 when you build the registry i am wondering what do you put in the class like:

in the registry we have public static var player:Player

What do i put in the Player.as class?

please pm me
Title: Re: Flash Game Dev Tips
Post by: Vax on Tue, Nov 20, 2012
Hey Richard, thanks for all the great tutorials. They really helped me out starting with Flixel. Keep up the good work!
p.s.: I would love to see a tutorial on FlxWeapon/Lasers/Beams/Raycasts/etc. ;)
Title: Re: Flash Game Dev Tips
Post by: Flynnv on Thu, Jan 10, 2013
It's ever possible to use "FlxG.follow" ? Now, we must use FlxCamera, no ?
Title: Re: Flash Game Dev Tips
Post by: Gama11 on Fri, Jan 11, 2013
It's ever possible to use "FlxG.follow" ? Now, we must use FlxCamera, no ?

Yeah, it changed from

Code: [Select]
FlxG.follow()
to

Code: [Select]
FlxG.camera.follow()
Title: Re: Flash Game Dev Tips
Post by: Flynnv on Fri, Jan 11, 2013
It's not obliged to create a new FlxCamera ?
Title: Re: Flash Game Dev Tips
Post by: Gama11 on Fri, Jan 11, 2013
It's not obliged to create a new FlxCamera ?

No, there already is one camera by default which you can use.
Title: Re: Flash Game Dev Tips
Post by: Flynnv on Fri, Jan 11, 2013
Ok, thanks for information :)
Title: Re: Flash Game Dev Tips
Post by: photonstorm on Thu, Oct 10, 2013
Un-sticking this thread, it's been a long time since I worked on these tutorials and things have moved on.