Author Topic: Flash Game Dev Tips  (Read 50091 times)

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Flash Game Dev Tips
« 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

Tip #2 - Flixel and TweenMax pausing together

Tip #3 - Bullet Manager, Part 1

Tip #4 - Bullet Manager, Part 2 (building a shmup)

Tip #5 - Configure your Games in Real-Time

Tip #6 - Setting-up FlashDevelop and Flixel for the first time

Tip #7 - Introducing the Flixel Power Tools

Tip #8 - Building a shoot-em-up Part 3, Return Fire

Tip #9 - Dealing with a lack of motivation to finish your game

Tip #10 - Flixels Internal Structure and Performance Tips

Tip #11 - The Flixel Display List Explained

Tip #12 - Building a Retro Platform Game in Flixel, Part 1

Tip #13 - Building a Retro Platform Game in Flixel, Part 2

Tip #14 - How to create a Flixel plugin (with tinted mirrored camera example!)

Tip #15 - Collectable Particles in Flixel (with demo and source)

I'll keep this post updated with the list of articles. But if you would like to request an article then please do so!
« Last Edit: Wed, Nov 30, 2011 by photonstorm »
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

tomii

  • Active Member
  • ***
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips
« Reply #1 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?
My online portfolio // www.tomii.se
My twitter

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips
« Reply #2 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.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

alteveer

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips
« Reply #3 on: Fri, Mar 4, 2011 »
What about FlxG.stage?

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips
« Reply #4 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.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

alteveer

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips
« Reply #5 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?

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips
« Reply #6 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.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

knivel

  • Member
  • **
  • Posts: 75
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #7 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));

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #8 on: Sun, Apr 3, 2011 »
Well spotted. Fixed and committed.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

RozzleDozzle

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #9 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/), 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!

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #10 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.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #11 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.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

XanderXevious

  • Contributor
  • ****
  • Posts: 360
  • Karma: +0/-0
    • View Profile
    • Deadly Alien Microbots
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #12 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.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #13 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.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Jimbo

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #14 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.

mightiest_hero

  • Member
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #15 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;
« Last Edit: Wed, Apr 20, 2011 by mightiest_hero »

Jimbo

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #16 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.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #17 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) ?
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Jimbo

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #18 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.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #19 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?
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius