Author Topic: Flixel Power Tools  (Read 79329 times)

Kurai

  • Active Member
  • ***
  • Posts: 173
  • Karma: +0/-0
    • View Profile
    • Urustar
Re: Flixel Power Tools
« Reply #60 on: Sat, Aug 13, 2011 »
Hi there,
first of all, thanks for making Flx Power Tools, it's helping me a lot. Just a total newbie question. I'm using FlxExtendedSprite, and I would like my sprite to change color when released from drag. I guess I should use mouseReleasedCallback, but I'm not understanding how exactly. Can you help me? Thanks!

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #61 on: Sun, Aug 14, 2011 »
How do you plan on colouring the sprite? With a specific sprite frame or via a filter or similar?
http://www.photonstorm.com



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

Kurai

  • Active Member
  • ***
  • Posts: 173
  • Karma: +0/-0
    • View Profile
    • Urustar
Re: Flixel Power Tools
« Reply #62 on: Sun, Aug 14, 2011 »
Simply using a greyscale sprite and changing the color attribute :)

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #63 on: Sun, Aug 14, 2011 »
Right then I'd use mousePressedCallback, you would just set it like this:

Code: [Select]
yourExtendedSprite.mousePressedCallback = changeColour;
yourExtendedSprite.mouseReleasedCallback = changeColour;


private function changeColour(obj:FlxExtendedSprite, x:int, y:int):void
{
if (obj.isPressed)
{
// change to the mouse-pressed colour
}
else
{
// change to the not-pressed colour
}
}
 
http://www.photonstorm.com



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

rageace

  • Member
  • **
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #64 on: Mon, Aug 15, 2011 »
I was wondering whether Flixel Power Tools can be used in a commercial project, and if so, what acknowledgements need to be made.

I read the license.txt but didn't understand what it meant.

Cheers.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #65 on: Mon, Aug 15, 2011 »
Yes they can be used in a commercial project. No acknowledgements need to be made at all unless you give away the source code, in which case you should include the license file with the tools source and ensure they have all of their headers intact.

I would very much appreciate if you emailed me to tell me if you use them in a game, but you don't have to. It's just great motivation to keep on working on them when people show me they're being used.
http://www.photonstorm.com



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

thePalindrome

  • Member
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
    • My site!
Re: Flixel Power Tools
« Reply #66 on: Wed, Aug 17, 2011 »
I installed everything according to the .pdf, but it's not working...

I create a FlxButtonPlus, and I get this:

E:\Code Projects\flash projects\What did us in\src\PlayState.as(16): col: 21 Error: Type was not found or was not a compile-time constant: FlxButtonPlus.
public var Button:FlxButtonPlus;
^
E:\Code Projects\flash projects\What did us in\src\PlayState.as(21): col: 17 Error: Call to a possibly undefined method FlxButtonPlus.
Button = new FlxButtonPlus(115, 115, clicked, null, null, 100, 20);


I have no idea why this isn't working...

Although, I have a "global" flixel at E:\flixel, am I supposed to put it there, or somewhere else?
He who knows not and knows not that he knows not is a fool, shun hum.   He who knows not and knows that he knows not is a child, teach him.   He who knows and knows not that he knows is asleep, wake him.   He who knows and knows that he knows is wise, follow him.
~Persian proverb

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #67 on: Wed, Aug 17, 2011 »
If you have a "global" Flixel install at E:\flixel then you need to put the photonstorm folder inside its plugin folder. The error you are getting is because it can't see the plugin classes.
http://www.photonstorm.com



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

thePalindrome

  • Member
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
    • My site!
Re: Flixel Power Tools
« Reply #68 on: Wed, Aug 17, 2011 »
If you have a "global" Flixel install at E:\flixel then you need to put the photonstorm folder inside its plugin folder. The error you are getting is because it can't see the plugin classes.

Okay, the path is this:

E:\flixel\org\flixel\plugin\photonstorm

that contains the Docs, Flixel Versions, and Test Suite folder, is it installed right?
He who knows not and knows not that he knows not is a fool, shun hum.   He who knows not and knows that he knows not is a child, teach him.   He who knows and knows not that he knows is asleep, wake him.   He who knows and knows that he knows is wise, follow him.
~Persian proverb

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #69 on: Wed, Aug 17, 2011 »
Nope - unzip the contents of the photonstorm.zip file into the plugins folder. The rest of the stuff is the Test Suite, put it somewhere else and keep it, it contains loads and loads of example code.
http://www.photonstorm.com



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

thePalindrome

  • Member
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
    • My site!
Re: Flixel Power Tools
« Reply #70 on: Wed, Aug 17, 2011 »
Ah, I was wondering why there was a .zip in the .zip folder!
So the classes should be at:
E:\flixel\org\flixel\plugin\photonstorm

is that right?
He who knows not and knows not that he knows not is a fool, shun hum.   He who knows not and knows that he knows not is a child, teach him.   He who knows and knows not that he knows is asleep, wake him.   He who knows and knows that he knows is wise, follow him.
~Persian proverb

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #71 on: Wed, Aug 17, 2011 »
Yup.
http://www.photonstorm.com



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

wonkytonk

  • Member
  • **
  • Posts: 73
  • Karma: +0/-0
  • don't panic
    • View Profile
Re: Flixel Power Tools
« Reply #72 on: Sat, Aug 20, 2011 »
hey photon, i'm running into some collision issues in my game, i'm using FlxCollisions, and i'm wondering if i'm doing everything i need to, putting:

if(FlxCollisions.pixelPerfectCheck(Sprite1,Sprite2))
FlxG.collide(Sprite1,Sprite2);

in the update function.

the problem i'm having is that when two (rotated) sprites are moving toward or alongside one another they can sometimes overlap and push through one another.
thanks!

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #73 on: Mon, Aug 22, 2011 »
Could you post up the code please and the assets as they willbe vital to debug this.
http://www.photonstorm.com



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

wonkytonk

  • Member
  • **
  • Posts: 73
  • Karma: +0/-0
  • don't panic
    • View Profile
Re: Flixel Power Tools
« Reply #74 on: Mon, Aug 22, 2011 »
hey, i pm'd you a link to the project.
thanks

Morgan

  • Member
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #75 on: Fri, Sep 2, 2011 »
Im pretty sure this is a noob question but here goes:

In your test suite examples such as simple keyboard controls for a platformer, you put the movement logic in the playstate rather than in the player class. Makes sense because you want to have all the code for the example in one class. I managed to shift your keyboard controls example into my player class without too much trouble.

Now im trying to do something similar with the space invaders weapons example. I want my character to shoot a lazer but I cant get it to work, mainly because i cant add(lazer.group) from within the player class. it gives an error "call to a possibly undefined method add".

Am I approaching this wrong?

Gardening for pleasure

rageace

  • Member
  • **
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #76 on: Sat, Sep 3, 2011 »
Hi Morgan,
I had a similar problem in one of my games, a solution could be to give the lazer object a copy of the playstate object, (using this), in the constructor, and storing it in an object in the lazer, say called currentPlayState.
You can then do currentPlayState.lazergroup.add(this).
(Providing lazergroup is visible). You would then have that object in case you needed to access other information from the playstate.

Alternatively (I haven't tried this way but it might be food for thought), you might be able to do something with a static function, called addtolazergroup, which you create in your playstate, and then call from your lazer class. I think you might run into problems this way thought with static/non static classes and variables.

I hope I have understood your problem correctly and this might help!


photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #77 on: Sat, Sep 3, 2011 »
This topic was covered recently in a thread by test84 called something like "need to redesign" have a look in there, failing that I'll reply later with an example.
http://www.photonstorm.com



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

Morgan

  • Member
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Flixel Power Tools
« Reply #78 on: Sat, Sep 3, 2011 »
Thanks for the replies guys!

I looked up test84's thread and seemed to be able to solve my problem with the simple line
Code: [Select]
FlxG.state.add(arrow.group).

But now i seem to have a conflict within my controls where i can only fire while im jumping. Below is my player code. Ive tried to find the problem myself, ive looked through the powertool files but to no avail. I have the feeling that the problem is staring me right in the face but im hoping a kind soul can enlighten a beginner.

here is the .swf, please dont laugh :) you can also see i need to make my arrow face the right way..

http://test.oid.co.nz/design/morgan_oliver/

thanks in advance.

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

//Player is the class which hold all the player data, sprites and animations
public class Player extends FlxSprite
{
[Embed(source='data/pit1.png')] protected var ImgPlayer:Class;
[Embed(source='data/arrow2.png')] protected var ImgArrow:Class;

public var JUMP:String = "jump"
public var MOVE:String = "move"
public var FALL:String = "fall"
public var IDLE:String = "idle"

private var arrow:FlxWeapon;

public function Player(X:Number,Y:Number):void
{
super(X, Y);
//Loads the character spritesheet
loadGraphic(ImgPlayer, true, true, 48, 48 );


width = 20;
height = 48;
offset.x = 11;
offset.y = 0;

JUMP = "jump";
MOVE = "move";
FALL = "fall";
IDLE = "idle";

addAnimation(JUMP, [5], 3);
addAnimation(MOVE, [3, 2, 1, 0], 15);
addAnimation(FALL, [4], 6);
addAnimation(IDLE, [0], 2);

arrow = new FlxWeapon("arrow", this, "x", "y");

// Tell the weapon to create 50 bullets using the bulletPNG image.
// The 5 value is the x offset, which makes the bullet fire from the tip of the players ship.
arrow.makeImageBullet(50, ImgArrow, 5);

// Sets the direction and speed the bullets will be fired in
arrow.setBulletDirection(FlxWeapon.BULLET_LEFT, 200);

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

//Control the sprite
FlxControl.create(this, FlxControlHandler.MOVEMENT_ACCELERATES, FlxControlHandler.STOPPING_DECELERATES, 1, true, false);
FlxControl.player1.setFireButton("SPACE", FlxControlHandler.KEYMODE_JUST_DOWN, 0, arrow.fire);
FlxControl.player1.setCursorControl(false, false, true, true);
FlxControl.player1.setJumpButton("UP", FlxControlHandler.KEYMODE_JUST_DOWN, 1000, FlxObject.FLOOR, 250, 200);

// Because we are using the MOVEMENT_ACCELERATES type the first value is the acceleration speed of the sprite
// Think of it as the time it takes to reach maximum velocity. A value of 100 means it would take 1 second. A value of 400 means it would take 0.25 of a second.
FlxControl.player1.setMovementSpeed(800, 0, 100, 200, 800, 0);

// Set a downward gravity of 400px/sec
FlxControl.player1.setGravity(0, 360);

FlxG.state.add(arrow.group);
}


override public function update():void
{

if (touching == FlxObject.FLOOR)
{
if (velocity.x != 0)
{
play(MOVE);
}
else
{
play(IDLE);
}
}
else if (velocity.y < 0)
{
play(JUMP);
}
else if ( velocity.y > 0 )
{
play(FALL);
}

super.update();
}

override public function destroy():void
{
// Important! Clear out the plugin otherwise resources will get messed right up after a while
FlxControl.clear();

super.destroy();
}


}
}
« Last Edit: Sat, Sep 3, 2011 by Morgan »
Gardening for pleasure

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Flixel Power Tools
« Reply #79 on: Sun, Sep 4, 2011 »
I'm not seeing anything obvious in that class that could cause this. Do you mind posting the complete project up somewhere?
http://www.photonstorm.com



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