Author Topic: Flixel Power Tools  (Read 74584 times)

xhunterko

  • Contributor
  • ****
  • Posts: 449
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #160 on: Thu, Apr 5, 2012 »
At the least, a working input box.

It'd be great to have some 3d support though. Like rotateX and its y and whatever people use to get a card flip effect going. Hope neither of those sound too crazy.
Now on twitter: http://twitter.com/xhunterko I made a game that's in alpha you can buy here: http://xhunterko.itch.io/wave-miner-alpha

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #161 on: Thu, Apr 5, 2012 »
I wish we could edit the bullet properties after we create a weapon. As of now, you should do all Setxxx before you make it and any Setxxx you do on your weapon is useless because bullets are already created with those properties you set at constructing it.

I also wrote a reload method and posted here for flxweapon, maybe it would help some people.
blog, twitter, Check out my award winning game, Rot Gut:

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #162 on: Wed, Apr 11, 2012 »
What's the best way to hide and disable a FlxButtonPlus? I can't "kill" it because it's a flxgroup and has two extendedsprites inside it so "kill"ing it just makes it invisible but actually works if you click it.
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 #163 on: Thu, Apr 12, 2012 »
Over-ride its kill method and just kill the children as well. Or create a "disabled" method that tells the children to ignore mouse clicks. Or add it to the github wishlist and I'll add it into the final version of FPT :)
http://www.photonstorm.com



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

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #164 on: Thu, Apr 12, 2012 »
Something strange happens when I did a similar thing, when I press the credits button for the 2nd time, it calls another registered click function, like you pressed another button as well.

For example when I press the Credits button, it hides the main menu group and shows the credits group but 2nd time, when I press the credits, it calls the hide menu group and then calls the show menu as well (which was registered to Back button in credits menu) !

I didn't do what you said exactly earlier but I overrided kill and revive and put alive and exists to false and true accordingly (since in the click code, I see you check those variables)
blog, twitter, Check out my award winning game, Rot Gut:

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #165 on: Thu, Apr 12, 2012 »
Over-ride its kill method and just kill the children as well

And what I should do in the revive one?

Or create a "disabled" method that tells the children to ignore mouse clicks.
Assume I have that function, how I can make them invisible then?

And I believe we don't need such because you already check that with exists, visible and active flags:
Code: [Select]
protected function onMouseUp(event:MouseEvent):void
{
if (exists && visible && active && (_status == PRESSED) && (_onClick != null) && (pauseProof || !FlxG.paused))
{
_onClick.apply(null, onClickParams);
}
}
blog, twitter, Check out my award winning game, Rot Gut:

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #166 on: Sun, Apr 15, 2012 »
Over-ride its kill method and just kill the children as well.

I believe it does it already, because FlxButtonPlus is a FlxGroup and FlxGroup's kill calls kill on each member.

Maybe I didn't get what you meant.
blog, twitter, Check out my award winning game, Rot Gut:

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Flixel Power Tools
« Reply #167 on: Sun, Apr 15, 2012 »
I think it's not possible, or atleast I don't know how, to over-ride kill method of FlxButtonPlus properly, because of this line in FlxGroup's kill:
if(Recurse && (basic is FlxGroup))
and since FlxButtonPlus is a FlxGroup, it will will run this:
(basic as FlxGroup).callAll(FunctionName,Recurse);
which causes to ignore FlxButtonPlus's own over-ridden kill() and call FlxGroup's kill().

EDIT 4:

I wanted to resort to that disable method you mentioned but that can't be done for the same reason I just said because of that thing in callAll thing.
« Last Edit: Sun, Apr 15, 2012 by test84 »
blog, twitter, Check out my award winning game, Rot Gut:

LegacyCrono

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #168 on: Wed, May 2, 2012 »
Hi, got this problem, im trying to make so that the player can shoot bullets by pressing the spacebar several times, but it just does not work for some reason :-\

This is my current code for setting the control and firerate for the weapon
Code: [Select]
// Set fire button and other settings
FlxControl.player1.setFireButton("SPACE", FlxControlHandler.KEYMODE_PRESSED, 0, Registry.pistol.fire);

// Set fire rate
Registry.pistol.setFireRate(0);

It works but does not perfrom the task i want i to, i just want to shoot one bullet/keypress so i thought if i changed to:
Code: [Select]
// Set fire button and other settings
FlxControl.player1.setFireButton("SPACE", FlxControlHandler.KEYMODE_JUST_DOWN, 0, Registry.pistol.fire);

// Set fire rate
Registry.pistol.setFireRate(0);

I would be able to perform the task, but instead, i can't fire any bullets at all  :-\
Some advice would be greatly appreciated  :)

I had the same issue, and managed to fix this by doing the following:
- Open org.flixel.plugin.photonstorm.FlxControl and find line 159:
Code: [Select]
override public function draw():void - And change it for:
Code: [Select]
override public function update():void

The problem happens because org.flixel.system.Input is updating before FlxControl has the opportunity to see the JUST_DOWN state of the key. When FlxControl runs on "draw()" the key state has already changed to "pressed", so the Fire button isn't triggered.
FlxControl currently updates on draw(), I have no idea why. Changing it to update() fixes this problem, but I don't know if it changes the behavior of something else on the Power Tools, so do this at your own discretion.
I hope photonstorm verify this and fix this problem soon.

Jeff

  • Active Member
  • ***
  • Posts: 127
  • Karma: +0/-0
    • View Profile
    • Entertainment Evolution
Re: Flixel Power Tools
« Reply #169 on: Tue, May 22, 2012 »
Just introduced myself to the power tools. Lots of great stuff there. I like the FX particularly.

Although I don't think I currently have much need for such a feature, I think one nice improvement for the extendedSprite would be to simplify creating entities that consist of multiple parts - in other words "sprites" that basically consist of multiple sprites.
Please give me feedback for my latest game in progress:
Blog: Entertainment Evolution

squidbot

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #170 on: Wed, May 23, 2012 »
I have a question about overlapping sprites and the "clickable" property. I have four sprites on top of each other, only one visible at a time to show different states (the context is a grid of sprites you can mouse over and it will highlight current, and differently highlight nearby sprites you can move to next.)

My assumption was that if I set clickable to false on all the sprites but one, it would always get the clicks (I'll call this the control sprite.) The problem is that sprites that are marked not clickable are still added to the control stack in checkForClick. This meant that depending on how my control sprite was sorted, it would sometimes get clicks, sometimes not.

Rather than sorting, I solved the problem by changing the update in FlxExtendedSprite from

Code: [Select]
isPressed == false && FlxG.mouse.justPressed()
to

Code: [Select]
if ((clickable == true) && (isPressed == false && FlxG.mouse.justPressed()))

Now, I could have sorted the control sprite to the top, but that seems a little unintuitive and would have required extra code to support. So my question is, am I thinking about the problem incorrectly? Should non-clickable sprites still be added in to the control stack on a click? I hate changing the library as it causes issues when I need to update (I have to merge it in rather than just replace it.) And for that matter, is there a way to do this besides sorting that I am completely missing?

Thanks!

(BTW, I'm very happy with the library, don't want to come off as negative!)


paala

  • Contributor
  • ****
  • Posts: 250
  • Karma: +0/-1
    • View Profile
Re: Flixel Power Tools
« Reply #171 on: Thu, Jun 7, 2012 »
Another useful thing would be  animated sprites with baked rotations...

natdempk

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #172 on: Thu, Jun 14, 2012 »
I have a question about using FlxMouseControl? I am getting an error saying:
Code: [Select]
Item.as(36): col: 66 Error: Access of possibly undefined property clickTarget through a reference with static type org.flixel.plugin.photonstorm:FlxMouseControl.
I also get the same error when I use isDragging and dragTarget in the code below.

I create a FlxMouseControl in Registry.as by doing:
Code: [Select]
public static var mouseCon:FlxMouseControl = new FlxMouseControl();
Then in Item.as I reference it in the update function as follows:
Code: [Select]
// equip an item by pressing equip key + clicking
if (FlxG.keys.pressed(Registry.equipkey) && Registry.mouseCon.clickTarget == this) {
Registry.player.equip(this);
}

// drag an inventory item to another slot
if (Registry.mouseCon.clickTarget == this && Registry.mouseCon.isDragging) {
// snap to mouse until released
while (!FlxG.mouse.justReleased())
{
Registry.mouseCon.dragTarget.x = FlxG.mouse.x;
Registry.mouseCon.dragTarget.y = FlxG.mouse.y;
super.update();
}
// when released
// find item released over - UNSURE
var tempItem:Item = Registry.mouseCon.clickTarget;
var oldSlot:int = this.invSlot;
// swap item positions + set new slots
Registry.player.inventory[tempItem.invSlot] = this;
this.invSlot = tempItem.invSlot;
Registry.player.inventory[oldSlot] = tempItem;
tempItem.invSlot = oldSlot;
}

It seems to be saying that property is possibly undefined, but I am not sure why? Am I even doing this the right way? Should I create one FlxMouseControl for my whole game to contol some GUI stuff or would I be better off making a separate FlxMouseControl for each item in my inventory?

Jeff

  • Active Member
  • ***
  • Posts: 127
  • Karma: +0/-0
    • View Profile
    • Entertainment Evolution
Re: Flixel Power Tools
« Reply #173 on: Sat, Jul 21, 2012 »
Is there a plan of adding tilemap support for the pixel perfect collision?  I put a sprite for collision in this case, but for some the pixelperfect check is functioning like the normal collision check: with enough rotation, it collides too early. Any idea, what the problem could be?
« Last Edit: Sat, Jul 21, 2012 by Jeff »
Please give me feedback for my latest game in progress:
Blog: Entertainment Evolution

ezknight

  • Member
  • **
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #174 on: Tue, Nov 13, 2012 »
Never mind. I improved my Googl-fu tonight and found the solution to my problem here: http://forums.flixel.org/index.php?topic=4855.0
My dragon class's update function wasn't calling super.update();

I am having an issue with the mouseReleasedCallback and mousePressedCallback parts of FlxExtendedSprite. I have been following the code in the balls mini game and it appears that I have done everything correctly, however the callback function never fires when I click the object it is attached to. I have added the FlxMouseControl plugin and have set the object as clickable via enableMouseClicks(true,true) but nothing happens.

I am extending the FlxExtendedClass with my own class. Could that be the problem?

This is my play state:

Code: [Select]
package
{
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;
 
public class DRPlayState extends FlxState
{
[Embed(source="images/mountains.png")] private var mountains:Class;

private var sprite:FlxSprite;
private var dragonSp:DragonSprite;
private var cameraWall:FlxGroup;
private var xdir:int;
private var ydir:int;
private var speed:int;

private var clickCounter:FlxText;
private var missCounter:FlxText;

public function DRPlayState()
{
}

override public function create():void
{
if (FlxG.getPlugin(FlxMouseControl) == null)
{
FlxG.addPlugin(new FlxMouseControl);
}

sprite = new FlxSprite(0,68,mountains);
add(sprite);
sprite = new FlxSprite(32,68,mountains);
add(sprite);
sprite = new FlxSprite(96,68,mountains);
add(sprite);
sprite = new FlxSprite(192,68,mountains);
add(sprite);

speed = 2;

clickCounter = new FlxText(10, 0, 100, "Hits: ");
clickCounter.size = 20;
add(clickCounter);
missCounter = new FlxText(500, 0, 100, "Misses: ");
missCounter.size = 20;
add(missCounter);

dragonSp = new DragonSprite();
//dragonSp.enableMouseClicks(false,true);
//dragonSp.mousePressedCallback = spriteClicked;

add(dragonSp);

cameraWall = FlxCollision.createCameraWall(FlxG.camera, FlxCollision.CAMERA_WALL_OUTSIDE, 8, false);
add(cameraWall);
}

/*private function spriteClicked(obj:DragonSprite, x:int, y:int):void
{
dragonSp.switchDragon();
dragonSp.hitCount++;
if(dragonSp.hitCount >= 10)
{
dragonSp.speed -= 5;
dragonSp.hitCount = 0;
}
}*/

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

if(dragonSp.missed >=5)
{
goToGameOver();
}
clickCounter.text = "Hits: " + dragonSp.clicks.toString();
missCounter.text = "Misses: " + dragonSp.missed.toString();
FlxG.collide(dragonSp,cameraWall);
}

private function goToGameOver():void
{
FlxG.switchState(new DROverState());
}

override public function destroy():void
{
FlxMouseControl.clear();

super.destroy();
}
}
}

Here is my Dragon Class:

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

public class DragonSprite extends FlxExtendedSprite
{
[Embed(source = "images/bio_dragon.png")]
private var bio_dragon:Class;
[Embed(source = "images/bone_dragon.png")]
private var bone_dragon:Class;
[Embed(source = "images/dragon.png")]
private var dragon:Class;
[Embed(source = "images/fire_dragon.png")]
private var fire_dragon:Class;
[Embed(source = "images/gold_dragon.png")]
private var gold_dragon:Class;
[Embed(source = "images/ice_dragon.png")]
private var ice_dragon:Class;
[Embed(source = "images/mud_dragon.png")]
private var mud_dragon:Class;
[Embed(source = "images/wind_dragon.png")]
private var wind_dragon:Class;
[Embed(source = "images/ghost_dragon.png")]
private var ghost_dragon:Class;
[Embed(source = "images/shadow_dragon.png")]
private var shadow_dragon:Class;

private var ImgDragon:Class;
private var dragonCount:int;
public var missed:int;
public var speed:int;
public var hitCount:int;

public function DragonSprite()
{
super(64, 64);

if (FlxG.getPlugin(FlxMouseControl) == null)
{
FlxG.addPlugin(new FlxMouseControl);
}

switchDragon();

missed = 0;
speed = 300;
hitCount = 0;

enableMouseClicks(true, true);
mousePressedCallback = spriteClicked;
}

public function switchDragon():void
{
var randDragon:int = randomRange(1,100);

elasticity = 1;

if (randDragon > 0 && randDragon <= 30)
{
velocity.x = randomRange(25, 50, true);
velocity.y = randomRange(25, 50, true);
loadGraphic(dragon);
} else if (randDragon > 30 && randDragon <= 40)
{
velocity.x = randomRange(25, 75, true);
velocity.y = randomRange(25, 75, true);
loadGraphic(fire_dragon);
} else if (randDragon > 40 && randDragon <= 50)
{
velocity.x = randomRange(25, 75, true);
velocity.y = randomRange(25, 75, true);
loadGraphic(ice_dragon);
} else if (randDragon > 50 && randDragon <= 60)
{
velocity.x = randomRange(25, 75, true);
velocity.y = randomRange(25, 75, true);
loadGraphic(wind_dragon);
} else if (randDragon > 60 && randDragon <= 70)
{
velocity.x = randomRange(25, 75, true);
velocity.y = randomRange(25, 75, true);
loadGraphic(mud_dragon);
} else if (randDragon > 70 && randDragon <= 80)
{
velocity.x = randomRange(30, 80, true);
velocity.y = randomRange(30, 80, true);
loadGraphic(bio_dragon);
} else if (randDragon > 80 && randDragon <= 85)
{
velocity.x = randomRange(35, 85, true);
velocity.y = randomRange(35, 85, true);
loadGraphic(bone_dragon);
} else if (randDragon > 85 && randDragon <= 90)
{
velocity.x = randomRange(40, 90, true);
velocity.y = randomRange(40, 90, true);
loadGraphic(ghost_dragon);
} else if (randDragon > 90 && randDragon <= 95)
{
velocity.x = randomRange(45, 95, true);
velocity.y = randomRange(45, 95, true);
loadGraphic(shadow_dragon);
} else if (randDragon > 95 && randDragon <= 100)
{
velocity.x = randomRange(50, 100, true);
velocity.y = randomRange(50, 100, true);
loadGraphic(gold_dragon);
}
y = randomRange(1,85);
x = randomRange(1,535);
dragonCount = 0;
}

override public function update():void
{
dragonCount++;
if (dragonCount > speed)
{
missed++;
switchDragon();
}

}

private function spriteClicked(obj:DragonSprite, x:int, y:int):void
{
//obj.kill();
switchDragon();
hitCount++;
if (hitCount >= 10)
{
speed -= 5;
hitCount = 0;
}
}

private function randomRange(minNum:Number, maxNum:Number, flip:Boolean = false):Number
{
var randNum:int = (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);

if (flip == true && randomRange(1,2) == 2)
{
randNum = randNum * - 1;
}
return randNum;
}
}
}

I have tried putting the spriteClicked function in both the dragon class and the play state. I have tried every combination of true/false in the first parameter of the enableMouseClicks function and mousePressedCallback/mouseReleasedCallback. I have used my dragon class as the type declaration of the first parameter of the callback function as well as FlxExtendedSprite. Nothing works.
« Last Edit: Wed, Nov 14, 2012 by ezknight »

Silvio Carréra

  • Member
  • **
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • Game Dev Blog
Re: Flixel Power Tools
« Reply #175 on: Mon, Feb 4, 2013 »
Code: [Select]
bow = new FlxWeapon("bow", actor, "x", "y");
bow.makeAnimatedBullet(50, AssetsRegistry.SPRITE_ARROW_18x25, 18, 25, [1, 2, 3], 3, true, 5, 5);
bow.setBulletDirection(FlxWeapon.BULLET_NORTH_EAST, 200);
bow.setFireRate(100);

add(bow.group);

It's shooting alright with:
Code: [Select]
bow.fireAtMouse();

Problem is, my arrows don't turn on the direction I'm shooting. So they are always poiting up. Is there a way to do this?

SuperDaimyo

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #176 on: Sun, Feb 24, 2013 »
Quote
I'm having this problem with FlxScrollZone (I know I'm not the only one), where it just stops working all of a sudden. Anyone know how to fix this?

Yeah pretty sure the problem is that the translation matrix values just get too big and can't cope any more. Not sure exactly what the limit is though, sorry - might be worth tracing out or something. It's the tx/ty values of the matrix. Could be that it exceeds the value of an integer maybe.

I think the solution would be to look for a "wrap point", i.e. rather than scroll infinitely (until it breaks!) you'd look to see if the translation values matched a seamless loop, and then reset them.

I have been experiencing this problem as well and have been staring at it for an hour. So far I have figured out that it is on the 103rd shift of the zone every time no matter what (even at 1 pixel a frame).  I will continue to fiddle and see if this can be solved as it messes up an otherwise really cool plugin.

Well, for a wrap point for horizontal scrolling only, I am using a line of code that would prevent tx/distanceX from approaching that 103 to closely and must wrap the value exactly when its a seamless loop but still working on the kinks. will post when i get it but i is teh bad at math, and have to consider possibility that tx/distanceX may reach 103 before a seamless wrap point :<.

Anyway, this is an ugly hack I still dont know the problem but maybe this might help those who just want to get it to work without stopping.

FlxScrollZone.as, line 235.

Code: [Select]
if (Math.abs(zone.scrollMatrix.tx) % Math.abs( (zone.distanceX*2))==0 &&  Math.abs(zone.scrollMatrix.tx) > zone.region.width )zone.scrollMatrix.tx=0;             

Settled on this, i use the abs because i read as3 didnt like modulus operations with negative numbers. In any case huge values of tx like if you set the distanceX with 100000 will break the function still. The condition tests if your x was translated at least once across its width and that it is in a "square" position then it just resets the tx.
« Last Edit: Mon, Feb 25, 2013 by SuperDaimyo »

Liberty Bell Studios

  • Member
  • **
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #177 on: Tue, Mar 19, 2013 »
Hi, I love your tools, they are great!

However, I have a problem with the alpha mask.

Specifically, I made a class to create custom UIs, and I need to apply two masks in sequence.

What happens is that after I apply the second mask, the results of the cuts from the first mask appear as black, instead of transparent. Basically, applying the second mask makes me lose the alpha from the first cut.

How can I fix this? Thanks!

John56465

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #178 on: Wed, Apr 24, 2013 »
I'm having an issue with the scrollFactor attribute inherited from native FlxSprite. I'm setting it to 0 on some FLxExtendedSprites for UI, and it works for the graphic (they always show up at the same place), but when I check their mouseOver the area isn't fixed, and it moves along the FlxG.camera (when it's moved using its scroll attribute). It's like FlxExtendedSprite.mouseOver doesn't work with the default Flixel camera.
Anyone have had the same issue?

Edit :
Well, I found a solution. Instead of checking sprite.mouseOver, I have to do
Code: [Select]
if (FlxMath.pointInFlxRect(mousePos.x, mousePos.y, sprite.rect))
{ ... }
which is almost the same thing as what mouseOver did in the first place. Pretty annoying. I tried centerOffsets, both with a 'true" and a "false" argument, but that didn't work. Posting the solution of course so people can see it.
« Last Edit: Wed, Apr 24, 2013 by John56465 »

DavydBezuglyi

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Flixel Power
« Reply #179 on: Thu, Nov 12, 2015 »
Поступили новые книги из Amazon

Joinery Gary ROROWSKI, Classic Joints with Power tools

Сам я оцифровку не потяну. Если есть желающие почитать т.е. отсканировать - Welcom