Author Topic: Flixel Power Tools  (Read 79325 times)

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #120 on: Thu, Nov 3, 2011 »
Sounds to me like you don't have your Project set-up correctly in FlashDevelop. It will only auto-complete source code it has direct access to. Have you created a project, put flixel and the tools into your src folder, etc? If you've done all this and SOME stuff auto-completes but not all, then you might just need to rebuild the Intrinsic cache - it's on a drop-down menu in FD somewhere, have a hunt!
http://www.photonstorm.com



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

Alextfish

  • Active Member
  • ***
  • Posts: 174
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #121 on: Thu, Nov 3, 2011 »
You may also need to make sure every file in your source code includes
Code: [Select]
import org.flixel.plugin.photonstorm.*;

caladan21ph

  • Member
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #122 on: Thu, Nov 3, 2011 »
Hmm. I did the classpath thing for flixel in one of the beginner tutorials. Ok, I'll try copying the whole flixel folder into the src.
Check out my game journal: http://alternatdev.wordpress.com

Apanda

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #123 on: Fri, Nov 4, 2011 »
I got a weird issue with FlxScrollZone. After some time it stops scrolling. The time depends on the speed I guess. I first wanted to make scroll speed up with adding this: speed = speed + 0.001; to update. But after 12 seconds scrolling stopped. So I thought it's all about speeding up and changed it to just 15 (private var speed:Number = 15;). But it stops anyway.  That's the code:
FlxScrollZone.add(back, new Rectangle(0, 0, back.width, back.height), -speed, 0, true);
back is the name of my scrolling background sprite.
back = new FlxSprite(0, 0, backImg);
Any ideas why this is happening?
« Last Edit: Fri, Nov 4, 2011 by Apanda »

antigirl

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #124 on: Thu, Dec 1, 2011 »
how do i make my player crouch,
looking at the platform example : http://www.photonstorm.com/archives/2247/flash-game-dev-tip-12-building-a-retro-platform-game-in-flixel-part-1

and the controlHandler class, how are left/right associate with the walk movement?
could i technically use firebutton to call any key/action

i.e:   
        addAnimation("duck", [3], 0, false);
   FlxControl.player1.setFireButton("SPACE", FlxControlHandler.KEYMODE_PRESSED, 250, nothing);

        public function nothing():void
    {
     play("duck");
    }



that doesnt work !?

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #125 on: Thu, Dec 1, 2011 »
how do i make my player crouch,
looking at the platform example : http://www.photonstorm.com/archives/2247/flash-game-dev-tip-12-building-a-retro-platform-game-in-flixel-part-1

and the controlHandler class, how are left/right associate with the walk movement?
could i technically use firebutton to call any key/action

i.e:   
        addAnimation("duck", [3], 0, false);
   FlxControl.player1.setFireButton("SPACE", FlxControlHandler.KEYMODE_PRESSED, 250, nothing);

        public function nothing():void
    {
     play("duck");
    }



that doesnt work !?
If you want  to use FPT's FlxControl, You achieve it via "FlxCont.create", look at this:
Code: [Select]
FlxControl.create(this, FlxControlHandler.MOVEMENT_ACCELERATES, FlxControlHandler.STOPPING_DECELERATES, 1, true, false);
blog, twitter, Check out my award winning game, Rot Gut:

Raf

  • Contributor
  • ****
  • Posts: 268
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #126 on: Thu, Dec 22, 2011 »
I got a weird issue with FlxScrollZone. After some time it stops scrolling. The time depends on the speed I guess. I first wanted to make scroll speed up with adding this: speed = speed + 0.001; to update. But after 12 seconds scrolling stopped. So I thought it's all about speeding up and changed it to just 15 (private var speed:Number = 15;). But it stops anyway.  That's the code:
FlxScrollZone.add(back, new Rectangle(0, 0, back.width, back.height), -speed, 0, true);
back is the name of my scrolling background sprite.
back = new FlxSprite(0, 0, backImg);
Any ideas why this is happening?
Got the same problem. Anybody know why this is happening? I'm really breaking my head over it (not to mention wasting an incredible amount of time and the fun of making games with Flixel)

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #127 on: Thu, Dec 22, 2011 »
Question about your CoinExplosion demo, why you are setting drag and elasticity at onEmit and why not setting them in constructor? I can understand playing the animation on onEmit, since it may preserve some performance maybe it won't work, but why the other two?

BTW, it's GREAT and works like a charm in my game!

-test84
blog, twitter, Check out my award winning game, Rot Gut:

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #128 on: Thu, Dec 22, 2011 »
I like to keep as little code as possible in a class constructor. There's no reason why it can't go in there though, just personal preference.
http://www.photonstorm.com



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

John Hutchinson (Johntron247)

  • Commodore 256
  • Contributor
  • ****
  • Posts: 392
  • Karma: +1/-0
  • I can has lazerz?
    • View Profile
    • Level X Games
Re: Flixel Power Tools
« Reply #129 on: Tue, Dec 27, 2011 »
I'm the same way.  I like to put things that will only ever need to be done once in the constructor.  Everything else I put in an overloaded revive() - or maybe create a method called reset() or something, if special parameters and such are needed.  I do that because somewhere down the road I'm probably going to want to recycle or reuse your objects. Having the overloaded revive() method, or a custom reset() function that gets called along with revive(), just makes that easier.  If I left that stuff in the constructor then I'm probably going to have to cut/paste it into the revive() function anyway, so when I create a new object class I try to just put it in that function right from the start.  That also reduces the possibility of forgetting something that needs to be done whenever you do recycle/reuse (not just once when the thing is created), or messing something up when I need to move the code around.

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #130 on: Sat, Dec 31, 2011 »
I'm the same way.  I like to put things that will only ever need to be done once in the constructor.  Everything else I put in an overloaded revive() - or maybe create a method called reset() or something, if special parameters and such are needed.  I do that because somewhere down the road I'm probably going to want to recycle or reuse your objects. Having the overloaded revive() method, or a custom reset() function that gets called along with revive(), just makes that easier.  If I left that stuff in the constructor then I'm probably going to have to cut/paste it into the revive() function anyway, so when I create a new object class I try to just put it in that function right from the start.  That also reduces the possibility of forgetting something that needs to be done whenever you do recycle/reuse (not just once when the thing is created), or messing something up when I need to move the code around.

Yes I'm with you on it, in other words it makes the class more reusable but since those coins were for that demo and only that, I wondered why he separated them.
blog, twitter, Check out my award winning game, Rot Gut:

LoveMeDo

  • Member
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
    • Bear Air
Re: Flixel Power Tools
« Reply #131 on: Fri, Feb 17, 2012 »
Hi Guys,

i recently did the "return fire" tutorial and i totally loved it. Especially the awesome FlxVelocity feature!

So i was trying to use this class for shooting homing missiles at enemies.

Unfortunately i don't know how to do this, because my EnemyManager (which we added in the create() function) is a FlxGroup and not a FlxSprite, which would be needed for FlxVelocity to work properly.

I know, i could skip the EnemyManager, but i really want to keep it for performance reasons.

I'm totally lost and every help is highly appreciated!

Sincerely

LoveMeDo

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #132 on: Sat, Feb 18, 2012 »
Is it a FlxGroup that has a FlxSprite inside it? If yes, access the FlxSprite with the FlxGroup, i.e. FlxGroup.FlxSprite.

I'm not sure if I understood you right but I sense that EnemyManager should be some kind of class that manages other things around and apparently don't usually have visual representations and thus are not FlxSprites. They usually have some FlxSprites inside them and they control their behavior someway. (Of course I'm trying to talk in context of your game)

So more light on the problem would definitely help.
blog, twitter, Check out my award winning game, Rot Gut:

LoveMeDo

  • Member
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
    • Bear Air
Re: Flixel Power Tools
« Reply #133 on: Sun, Feb 19, 2012 »
Hi test84,
thank you for your reply!

As you said, the enemymanager class is a flxgroup class, which handles the recycling of enemies (flxsprite).
The problem is, that im just declaring the enemymanager class in my registry and adding it in my create function. So i don't know how to adress a single enemy in the flxvelocity call.

Adding the Enemy (flxsprite) class to the registry didn't work either.

I was trying this with the "moveToObject" method btw.

I think, that the "moveToPoint" method could also work, if i could figure out how to pass the x,y coordinates of the enemies to the method.
But sadly, i got stuck on this one too  :'(


Best regards

lovemedo
« Last Edit: Tue, Feb 21, 2012 by LoveMeDo »

Chelnok

  • Contributor
  • ****
  • Posts: 257
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #134 on: Tue, Feb 21, 2012 »
I'm feeling lazy today, and probably tomorrow :) ..so if anyone have done collecting bullets and / or reload system with Great FlxWeapon, drop some code here or give some tips how it would be smart to do.

Edit:
I found this one:
http://forums.flixel.org/index.php/topic,5552.msg31281.html#msg31281

Looks fine, but another solution is always wellcome.
« Last Edit: Tue, Feb 21, 2012 by Chelnok »

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #135 on: Tue, Feb 21, 2012 »
Hi test84,
thank you for your reply!

As you said, the enemymanager class is a flxgroup class, which handles the recycling of enemies (flxsprite).
The problem is, that im just declaring the enemymanager class in my registry and adding it in my create function. So i don't know how to adress a single enemy in the flxvelocity call.

Adding the Enemy (flxsprite) class to the registry didn't work either.

I was trying this with the "moveToObject" method btw.

I think, that the "moveToPoint" method could also work, if i could figure out how to pass the x,y coordinates of the enemies to the method.
But sadly, i got stuck on this one too  :'(


Best regards

lovemedo

So make a function call in your enemy manager class and based on the situation you want, do whatever you want with that enemy. You have to explain more about your problem, why do you want to change velocity of that specific enemy? Is it because he collided with something? Is it because he "saw" the player? whatever it is, you can detect it and call a function on him. i.e. if you collide two objects, the call back function gives you access to those that collided as parameters to the callback function.

(As the problem is no longer Flixel Power Tools related, I suggest we continue this in a separate topic)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

I'm feeling lazy today, and probably tomorrow :) ..so if anyone have done collecting bullets and / or reload system with Great FlxWeapon, drop some code here or give some tips how it would be smart to do.

Edit:
I found this one:
http://forums.flixel.org/index.php/topic,5552.msg31281.html#msg31281

Looks fine, but another solution is always wellcome.

I'm using the code I put there for a while and haven't noticed anything. Rule of the thumb is, you have to have a pool of bullets and each time you want a new bullet, get it out of that pool with recycle/getFirstAvailabe/getFirstXXX methods, so you won't be "new"-ing bullets on each shoot.

It's performance is not bad because I'm using it in my machine gun with no problem so far.

Code is fairly simple though.
blog, twitter, Check out my award winning game, Rot Gut:

LoveMeDo

  • Member
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
    • Bear Air
Re: Flixel Power Tools
« Reply #136 on: Thu, Feb 23, 2012 »
First of all, thank you for taking your time and your patience, test84. Really appreciated.

In a nutshell, what I want is a homing missile (as a weapon power-up) for the playing character.
This is part of my EnemyManager Class (from Phontonstorm's shooter tutorial)

Code: [Select]
package 
{
import org.flixel.*;
import flash.utils.getTimer;
import org.flixel.plugin.photonstorm.*;


public class EnemyManager extends FlxGroup
{
private var lastReleased:int = 1;
private var releaseRate:int;
public var enemy:Enemy;

public function EnemyManager()
{
super();

for (var i:int = 0; i < 40; i++)
{
add(new Enemy);
}
}

public function release():void
{
enemy = Enemy(getFirstAvailable());

if (enemy)
{
enemy.launch();
}
}

override public function update():void
{
super.update();

releaseRate += 1;


if (releaseRate > 120)
{
resetRelease();
release();

}
}

Part of the EnemyClass
Code: [Select]
package 
{
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;

public class Enemy extends FlxSprite
{
[Embed(source = "D:/Game_Dev/FlashDevelop/PSTuT/PSTut/lib/space-baddie.png")] private var enemyPNG:Class;
[Embed(source = "D:/Game_Dev/FlashDevelop/PSTuT/PSTut/lib/space-baddie2.png")] private var enemy2PNG:Class;

private var randomEnemy:int; // Holds the randomly generated integer used to determine which type of enemy spawns
public var randomEnemyTag:String; // Holds the string used to tell PlayState what enemy to spawn
public var scoreValue:uint;

private var fireTime:FlxDelay;
private var willFire:Boolean = false;


public function Enemy()
{
super(0, 0);

exists = false;
}

public function launch():void
{
x = FlxG.width;
y = Math.random() * (FlxG.height - 100) + 50;

randomEnemy = FlxG.random() * 0; // Generates a random integer 0-1

if (randomEnemy == 0)
{
exists = true;
loadGraphic(enemyPNG, false, false, 80, 80);
velocity.x = -150;
randomEnemyTag = "EnemyOne";
scoreValue = 10;

health = 1;
}
else if (randomEnemy == 1)//
{
exists = true;
loadGraphic(enemy2PNG, false, false, 80, 80);
velocity.x = -100;
randomEnemyTag = "EnemyTwo";
scoreValue = 50;

health = 3;
}

Part of the RegistryClass
Code: [Select]
package 
{
public class Registry
{
public static var ship:Ship;
public static var bullets:BulletManager;

public static var enemies:EnemyManager;
public static var enemyBullets:EnemyBulletManager;

public static var bosses:BossManager;
public static var bossBullets:BossBulletManager;

public static var fx:Fx;
public static var hud:HUD;
public static var powerUps:PowerUpManager;

public function Registry()
{
}

public static function init():void
{
ship = new Ship();
bullets = new BulletManager();

enemies = new EnemyManager();
enemyBullets = new EnemyBulletManager();

bosses = new BossManager();
bossBullets = new BossBulletManager();

fx = new Fx();
hud = new HUD();
powerUps = new PowerUpManager();
}

Now implementing the enemy's homing missiles while shooting at the playable character was pretty easy (s. Photonstorm's tutorial)
Code: [Select]
public function enemyFire(bx:int, by:int):void
{
x = bx;
y = by;

FlxVelocity.moveTowardsObject(this, Registry.ship, speed);

exists = true;
}

ship is the playable character.

I just can't use FlxVelocity by swopping the parameters like this:  FlxVelocity.moveTowardsObject (ship, Registry.enemies, speed). because Registry.enemies is not a FlxSprite as presupposed to use FlxVelocity. So, how can my ship have homing missiles without discard the EnemyManager Class?

Hope this helps und have a great day,
lovemedo

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #137 on: Fri, Feb 24, 2012 »
Assuming that you want to shoot missile at one enemy shop, you have to target one specific ship. How do you select one sheep to shoot at? If it's under mouse click, use mouse, if it's nearest enemy, do a method call and make that ship special from the rest, or any other way that you have for your game logic. Then with that ship in hand, pass it to this function of yours.

If you want to shoot them all, either have a loop and call this function for each member of your enemies group or have a method to do it for you. (or extend that method if that decreases performance).

There are several other ways I can think of, but let's not get ahead of ourselves here.
blog, twitter, Check out my award winning game, Rot Gut:

7heSAMA

  • Member
  • **
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #138 on: Sun, Feb 26, 2012 »
Hey Photonstorm, if you're reading this, I absolutely love the power tools and the flash dev tips, thanks so much for taking the time to make them. :D

...

...

ok yes this is about more than simple thanks. I was wondering if anyone knew how to apply the GlitchFX to FlxText. Of course I could make image text files, but besides being really memory-intense I would like to be able to dynamically generate the text, eg have the player input the name and then use that in glitched-up radio dialogue. Only idea I had was that it might be possible to generate image files from text in-game but that sounds pretty reasource-heavy, too, and I'm not even sure it's possible (so far it looks like "no"...).

Relevant.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #139 on: Mon, Feb 27, 2012 »
FlxText just creates an image file anyway, if you look at it you'll see it extends FlxSprite and the "text" is stored in the pixels value. So basically I'm pretty sure Glitch will just work out of the box with it.
http://www.photonstorm.com



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