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

janrey10

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

^_^
Thanks for the help

foosety

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


photonstorm

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



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

foosety

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

paala

  • Contributor
  • ****
  • Posts: 250
  • Karma: +0/-1
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #44 on: Wed, May 25, 2011 »
Is this version of power tools compatible with flixel 2.43. If not, where can I download older versions?

photonstorm

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



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

paala

  • Contributor
  • ****
  • Posts: 250
  • Karma: +0/-1
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #46 on: Thu, May 26, 2011 »
Thank you so much. Your work is so great!

foosety

  • Member
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #47 on: Wed, Jun 1, 2011 »
How is the development for FlxBar coming along?
I'm really eager to put it to use  :-*

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #48 on: Wed, Jun 1, 2011 »
Finished - just doing new Test Cases for it :)
http://www.photonstorm.com



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

VictorGrunn

  • Member
  • **
  • Posts: 79
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #49 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);
         }         
      }
« Last Edit: Wed, Jun 1, 2011 by VictorGrunn »

Manji

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Flash Game Dev Tips + Flixel Power Tools
« Reply #50 on: Tue, Jun 7, 2011 »
Hi,

is there any way to change the Button Border color ?

maxbadger

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
    • Comics(non games)
Re: Flash Game Dev Tips
« Reply #51 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.

jyrde

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

grexbo

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


grexbo

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

Hope Photonstorm does not mind.

Note that you have to manually add Flixel and Powertools sources to your project.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flash Game Dev Tips
« Reply #55 on: Thu, Jul 21, 2011 »
Nice one grexbo - thanks :)

I posted Tip 10 today as well, which may be of some interest to those wanting to know how Flixel is doing stuff internally.
http://www.photonstorm.com



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

NateTheGreatt

  • Member
  • **
  • Posts: 83
  • Karma: +0/-0
  • smell the sound
    • View Profile
    • n8bit
Re: Flash Game Dev Tips
« Reply #56 on: Sat, Jul 30, 2011 »
You are beauty. How do I buy you a coffee??
"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away."
-Antoine de Saint-Exupery

photonstorm

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



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

NateTheGreatt

  • Member
  • **
  • Posts: 83
  • Karma: +0/-0
  • smell the sound
    • View Profile
    • n8bit
Re: Flash Game Dev Tips
« Reply #58 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...
"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away."
-Antoine de Saint-Exupery

photonstorm

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



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