Author Topic: Flixel Power Tools  (Read 79272 times)

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #100 on: Tue, Oct 11, 2011 »
Thanks for all the effort, hope we can do stuff in return.
blog, twitter, Check out my award winning game, Rot Gut:

foosety

  • Member
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #101 on: Fri, Oct 14, 2011 »
Hey is flxScreenGrab only for local use? I tried grabbing a picture when my swf was online but no luck. Any suggestions?

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #102 on: Fri, Oct 14, 2011 »
Correct. It'd be easy enough to hook to work online - you'd have to ensure that the grab function is the recipient of the KeyboardEvent directly - it can't be passed through another function (that is what fires the sandbox error)
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: Flixel Power Tools
« Reply #103 on: Sat, Oct 15, 2011 »
Correct. It'd be easy enough to hook to work online - you'd have to ensure that the grab function is the recipient of the KeyboardEvent directly - it can't be passed through another function (that is what fires the sandbox error)

You're right whenever I put it into another function it fires a sandbox error. I attached it to my onClick function from one of my FlxButtonPlus objects which works fine. However now I've run into another dilemma. I'm trying to hide the "take picture" buttons when the user clicks on "take picture". I place picBtn.visible = false; before the screenGrab function in my onClick function, but the screen grab always seems to take the picture before the buttons are hidden. Any ideas for this?

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #104 on: Sun, Oct 16, 2011 »
The problem is the call to visible = false doesn't take effect until the next flixel render, but the screen grab event happens immediately. My suggestion would be to not have the "take picture" buttons as part of flixel at all. Insert them as normal display objects on-top of your game, and then the grab function can hide them before the grab.
http://www.photonstorm.com



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

licebeam

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #105 on: Tue, Oct 18, 2011 »
I'm having a hard time with bullet collision,

this is my update function, it seems as though using current bullet is out of the question with high rate of fire, because it counts the last bullet fired, so if there is two or more on the screen the don't, kill();

Code: [Select]
override public function update() :void
{
this.immovable = true;

if (FlxG.collide(this, PlayState.lazerbeam.group))
{
healthPoints -= 1;
PlayState.lazerbeam.currentBullet.kill();
play("walk");

}
if (healthPoints == 0)
{
this.kill();
}
}

If there is any way to solve this please let me know, I'm new to this.

Alextfish

  • Active Member
  • ***
  • Posts: 174
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #106 on: Wed, Oct 19, 2011 »
The more normal way to do it is to have your update function call something like

Code: [Select]
FlxG.collide(object1, PlayState.lazerbeam.group, objectHitLaser)
and then have another function

Code: [Select]
public function objectHitLaser(object1:FlxSprite, laserObject:FlxSprite) {
  object1.hurt(1);
  laserObject.kill();
}

Note that FlxSprites have a health variable already, and a hurt(amountOfDamage) function which will take care for you of things like decreasing health and calling kill() when it runs out, so you don't have to do that yourself.

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #107 on: Wed, Oct 19, 2011 »
I'm having a hard time with bullet collision,

this is my update function, it seems as though using current bullet is out of the question with high rate of fire, because it counts the last bullet fired, so if there is two or more on the screen the don't, kill();

Code: [Select]
override public function update() :void
{
this.immovable = true;

if (FlxG.collide(this, PlayState.lazerbeam.group))
{
healthPoints -= 1;
PlayState.lazerbeam.currentBullet.kill();
play("walk");

}
if (healthPoints == 0)
{
this.kill();
}
}

If there is any way to solve this please let me know, I'm new to this.

umm, don't you have to call super.update() before everything?
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 #108 on: Wed, Oct 19, 2011 »
You can call it at the start or end of the update function, doesn't really matter too much (sometimes you need it in a specific place, but it's rare). But it does appear to be missing from the above code entirely.
http://www.photonstorm.com



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

licebeam

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #109 on: Wed, Oct 19, 2011 »
Thanks guys, it works now and I'm new to this so I forget things like super.update(); =(

I have another question.

Would it be inappropriate to use flxweapon as a particle emitter?
The code seems perfect for what I want to do, is there any reason I wouldn't want to?

An example would be, I have a breakable door and I want the player to have some sort of feedback when it's hit, my first reaction was to try and make it spit back some particles like a spark or pieces breaking off kinda.

Morgan

  • Member
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #110 on: Thu, Oct 20, 2011 »
Gardening for pleasure

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #111 on: Thu, Oct 20, 2011 »
licebeam - I'd use an FlxEmitter for this really
http://www.photonstorm.com



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

licebeam

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #112 on: Thu, Oct 20, 2011 »
Ah, thanks again guys, I got an emitter working!

I was fiddling around with using flx weapon to do it before you replied and it just isn't the same haha! =)

datorum

  • Active Member
  • ***
  • Posts: 165
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #113 on: Mon, Oct 24, 2011 »
first of all, thx a lot for this great library.

now my question, am I doing something totally wrong or using the wrong version together?
I am using flixel 2.55 and put Flixel Power Tools 1.9 into the plugin folder. Now I try to use the FlxButtonPlus, which raises a lot of errors due to the fact that FlxGroup is derived from FlxBasic, which doesn't have x,y,width,height, etc. anymore. (FlxButtonPlus is derived from FlxGroup).

Code: [Select]
\src\com\photonstorm\flixel\FlxButtonPlus.as(113): col: 4 Error: Access of undefined property x.
EDIT:
sorry, I had an old version of Flixel Power Tools also in the source directory ;)  ;D
« Last Edit: Mon, Oct 24, 2011 by datorum »

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #114 on: Mon, Oct 24, 2011 »
I was going to say - it shouldn't be in com\photonstorm at all! It should be in org\flixel\plugin\photonstorm :)
http://www.photonstorm.com



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

datorum

  • Active Member
  • ***
  • Posts: 165
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #115 on: Mon, Oct 24, 2011 »
photon, just found out that FlxExtendedButton doesn't support the color/alpha properties of the sprites used for the button images.
I don't know if it is intentional or not, if not, here you find the "updated" code - was really hard  ;)
http://forums.flixel.org/index.php/topic,5364.0.html

datorum

  • Active Member
  • ***
  • Posts: 165
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #116 on: Tue, Oct 25, 2011 »
maybe a bug report, what exactly does the code "if (_pressed) ..." perform?

Code: [Select]
public function loadGraphic(normal:FlxSprite, highlight:FlxSprite):void
{

buttonNormal.pixels = normal.pixels;
buttonHighlight.pixels = highlight.pixels;


width = buttonNormal.width;
height = buttonNormal.height;

if (_pressed)
{
buttonNormal.visible = false;
}
else
{
buttonHighlight.visible = false;
}
}


I have this function:
Code: [Select]
public function setEarned(Earned:Boolean):void
{
earned = Earned;

if (earned)
{
loadGraphic(spriteEarned, spriteEarnedHigh);
}
else
{
loadGraphic(spriteNotEarned, spriteNotEarnedHigh);
}

}

which called from the constrcutor performs fine, but called in update() results in the highlighted sprite disappearing.
I commented out "if (_pressed)" and now it works.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #117 on: Tue, Oct 25, 2011 »
_pressed is just an internal var that toggles when the button is held down or not (i.e. pressed) and swaps between two images accordingly. To be honest this class is going in 2.0 to be replaced by a proper UI class.
http://www.photonstorm.com



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

datorum

  • Active Member
  • ***
  • Posts: 165
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #118 on: Mon, Oct 31, 2011 »
FlxButtonPlus - labels don't have scrollfactor set properly, cause usually you won't need it ;) but I have a scrolling level in the background :)

Code: [Select]
if (Label != null)
{
textNormal = new FlxText(X, Y + 3, Width, Label);
textNormal.setFormat(null, 8, 0xffffffff, "center", 0xff000000);
textNormal.scrollFactor.x = 0; //added
textNormal.scrollFactor.y = 0; //added

textHighlight = new FlxText(X, Y + 3, Width, Label);
textHighlight.setFormat(null, 8, 0xffffffff, "center", 0xff000000);
textHighlight.scrollFactor.x = 0; //added
textHighlight.scrollFactor.y = 0; //added

add(textNormal);
add(textHighlight);
}

caladan21ph

  • Member
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #119 on: Thu, Nov 3, 2011 »
So I was trying out the code for the sprite rotation in the power tools, and somehow setRotationSpeed and the other setRotation stuff does not appear in my Flash Develop(the little notes that pop up when typing code). This goes the same for starFieldFx.create() . Is this a problem with my flash develop or a version of my powertools? The thing is, the code works if I cut and paste it from the source. Thanks!
Check out my game journal: http://alternatdev.wordpress.com