Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - moly

Pages: [1]
releases / Re: flixel-android 0.5
« on: Thu, Dec 20, 2012 »
What I want is for the game to appear as it does, normal aspect ratio - kind of like here ( But I want the gamepad to extend into the black area. Right now it's constrained to be within the drawn game stage area. Moving it to the black area would be more comfortable, and would take up less screen space for players too.

I think the easiest way to do this right now is to use scrolling. In your main class set the default scalemode to FILL_X:

Code: [Select]
public TiledMap2Demo()
    super(320, 240, PlayState.class, 2, 40, 40, false, FlxCamera.FILL_X);

Now in the PlayState, you need to set up your camera like this:

Code: [Select]
private FlxGamePad _pad;

public void create()

    FlxG.width =;

    //Scroll the camera to the centre of the screen = -(FlxG.width - / 2;

    //Set the cameras width to the screen width = FlxG.width;

    //Create gamepad and set it to ignore the camera scroll
    pad = new FlxGamePad(FlxGamePad.FULL, FlxGamePad.A_B);
    pad.setAll("scrollFactor", new FlxPoint(0,0));

    //Optional: set FlxG.width back to the original game width if you need to
    FlxG.width = 320;


Here's how it looks in the collision demo:

I'm going to work on fixing it so that you don't need to mess with FlxG.width, but this should work for now.

Waiting for Adam to return and carry Flixel to infinity and beyond is silly, there's very little incentive for him to work within the Flash platform.

It just doesn't make sense to keep developing an engine that caters to a platform that doesn't support business models that can sustain a developer through bigger and bigger projects.

I agree that he shouldn't be expected to return to full development. However, seeing as flixel is probably the most well known and widely used Flash game framework currently out there, I kind of feel that he should ensure that the project is still receives basic maintenance in some way. As I've said in my previous posts, I'm not looking for any new features or anything like that, just that the currently reported bugs are addressed. Many of the bugs have fixes already provided for them, so it would take literally 5 minutes to check each one and merge them in. If the problem is purely financial, I would prefer he put ads on his websites or ask for donations or something, rather than simply leaving flixel riddled with major issues.

help / Re: Weird minor issues with (easy) workarounds
« on: Fri, Sep 28, 2012 »
It would be very helpful if you posted your test code.

help / Re: Has anyone fixed FlxQuadTree yet?
« on: Fri, Sep 28, 2012 »
It's a little awkward, but the issue you mention would not occur in Zaphod's fork. The only place FlxQuadTrees are used within the engine is in FlxG.overlaps, like so:

Multiple FlxQuadTree's are also created within FlxQuadTree::addObject. You can check for yourself that issue does occur in his fork, add a trace to FlxQuadTreeCache::recycle:

Code: [Select]
public function recycle(x:Number, y:Number, width:Number, height:Number, parent:FlxQuadTree = null):FlxQuadTree
    var tree:FlxQuadTree;
    var i:int = 0;

    while (i < _length)
        tree = _trees[i] as FlxQuadTree;
        if (tree.exists == false)
            tree.reset(x, y, width, height, parent);
            return tree;

    return add(new FlxQuadTree(x, y, width, height, parent));

I tried this on the Mode demo and at times it took up to 80 iterations to find a tree to recycle. Zaphod's pooling classes are highly inefficient for this purpose.

flixel is neither abandoned nor expecting an imminent update

That's a pretty vague answer. Not abandoned, but not being updated? I can appreciate being busy but it would only take five minutes to make a forum/blog post explaining the situation like Chevy Ray did for FlashPunk:

Is anyone leaning towards taking up the torch, or is it sort of a free-for-all right now?

From what I can tell it's pretty much a free for all. There are a couple of forks that I linked to in my first post, but they all seem to contain different fixes. Looking through the v3.0 planning thread it seems like Adam was really keen on implementing Stage3D, in which case I guess axel would probably be the closest thing to "taking up the torch", although it's obviously pretty different to flixel.

I think you moly, you want to further develop flixel... You can also make your own unofficial updates, and post here on forums..

I'd be interested in developing a flixel v2.56 that tries to fix most of the bugs in the issues queue and make some other behind the scenes tweaks. A lot of these issues are fixed with only one or two lines, so I think you could probaby do it in just a couple of days. I wouldn't really want to try to develop flixel any further than that though, ie adding new features or making more substantial changes.

help / Re: Has anyone fixed FlxQuadTree yet?
« on: Wed, Aug 29, 2012 »
I've done this kind of optimization in my fork: (there are couple other fixes and improvements mentioned on forum)
This optimization affected FlxObject, FlxQuadTree, FlxList and FlxG classes so engine can reuse lists, quadtrees and rectangles without constantly creating them.

It looks like your recycle function is iterating through the entire pool until if finds an object with exists == false, which will become very slow as the pool increases in size. My code only stores destroyed objects in the pool, so you can just fetch the first item off the top.

help / Re: Has anyone fixed FlxQuadTree yet?
« on: Wed, Aug 29, 2012 »
I can't find any function named "overlapTileMap" in flixel v2.55. Could you be more specific about what code you are referring to?

How are you updating the acceleration? If you have anything like
Code: [Select]
sprite.acceleration++; or
Code: [Select]
sprite.velocity-=2; that will cause different behaviours at different framerates. You should be using something like
Code: [Select]
sprite.acceleration += (_accInc * FlxG.elapsed); instead.

Edit: Just saw that the acceleration is constant. I'm guessing you're just setting
Code: [Select]
sprite.acceleration = 5; then? Perhaps that's not the problem.

According to google, Flash has a limit of 32 different sound channels. Are you trying to play over 32 sounds at once?

help / Re: Strange FlxTilemap behavior
« on: Tue, Aug 28, 2012 »
I think you've encountered this bug:

The suggested fix is to modify the FlxTilemap::loadMap() method as shown:

Code: [Select]
public function loadMap(MapData:String, TileGraphic:Class, TileWidth:uint=0, TileHeight:uint=0, AutoTile:uint=OFF, StartingIndex:uint=0, DrawIndex:uint=1, CollideIndex:uint=1):FlxTilemap
    auto = AutoTile;
    _startingIndex = StartingIndex;

    var i:int = _buffers.length;
    while(i < l)
        (_buffers[i++] as FlxTilemapBuffer).destroy();
    _buffers = new Array();

    //Figure out the map dimensions based on the data string
    var columns:Array;
    var rows:Array = MapData.split("\n");
    widthInTiles = 0;
    heightInTiles = rows.length;

You might find there's some other stuff that needs to be reset too.

The only reason I can think of for updating quicker than you draw is more accurate collision. A lower framerate can theoretically cause collisions to skip, especially with small, fast moving items like bullets.

help / Re: Race your ghost?
« on: Sun, Aug 26, 2012 »
I think you will have to write your own code that parses the FlxReplay data. You could create a class that inherits from FlxReplay, then override playNextFrame so that it controls the ghost car rather instead of calling Input::playback().

help / Re: Has anyone fixed FlxQuadTree yet?
« on: Sun, Aug 26, 2012 »
I think I've solved this myself. I went looking through the flixel-ios code on github and found this:

While I don't know Objective-C, the code near the top of the file seems to be object-pooling related. I decided then to try and implement something similar in the Flash version. First I created a very basic object pool class:

Code: [Select]
package org.flixel.system
     * ...
     * @author moly
    internal class ObjectPool
        protected var _objects:Array;
        protected var _objectClass:Class;

        public function ObjectPool(ObjectClass:Class)
            _objectClass = ObjectClass;
            _objects = new Array();

        public function getNew():*
            var object:* = null;
            if (_objects.length > 0)
                object = _objects.pop();
                object = new _objectClass();
            return object;

        public function disposeObject(OldObject:Object):void

Then I altered FlxQuadTree and FlxList to use the new class:

The main changes are:
FlxQuadTree and FlxList both have their own pool.
When a FlxQuadTree or FlxList is destroyed, it gets added to its pool so that it can be resused.
If FlxQuadTree wants to create a new object, it gets it from the relevant pool instead.

I also modified FlxG::overlap() like so:
Code: [Select]
static public function overlap(ObjectOrGroup1:FlxBasic=null,ObjectOrGroup2:FlxBasic=null,NotifyCallback:Function=null,ProcessCallback:Function=null):Boolean
    if(ObjectOrGroup1 == null)
        ObjectOrGroup1 = FlxG.state;
    if(ObjectOrGroup2 === ObjectOrGroup1)
        ObjectOrGroup2 = null;

    FlxQuadTree.divisions = FlxG.worldDivisions;
    var quadTree:FlxQuadTree = FlxQuadTree.quadTreePool.getNew();
    var result:Boolean = quadTree.execute();
    return result;

To test, I modified the particles demo from the flixel features page to use 300 particles and to check for overlaps between all of them. On my laptop I managed around 40fps for standard flixel and 55fps for my modified version with object pooling, which is pretty good. As you'd expect, the higher the number of overlap checks the more noticeable the difference; I tested a number of simpler games and they didn't seem to improve as much.

Hopefully this is useful to someone else. Let me know if anyone finds any problems with anything here.

The official flixel project on github hasn't been updated in over a year, despite there being 68 reported issues and 14 pull requests. I've noticed a couple of people have made forks to fix these issues, for example this one: which also includes some organisational improvements and fixes to the input system, and this one: which has a lot of Camera improvements and minor performance fixes.

I'm wondering then if anyone is trying to unify these fixes in any way? Is there a semi-official github project somewhere that has all these patches in one place? It seems the only way to have an "up to date" flixel at the moment is to spend time going through the forums and pull requests and collecting all the different contributions yourself.

The FlashPunk website is currently linking to a fork of the original project that is being maintained by someone else, why does not flixel not have something similar?

help / Re: Input Text Field
« on: Sat, Aug 25, 2012 »
The easiest way is probably just to add a Flash textfield to the stage, something like:

Code: [Select]
var textField:TextField = new TextField();
textField.type = TextFieldType.Input;
//I think this should work, otherwise add it to FlxG.stage;

If you want a solution that's better integrated into flixel I wrote my own class a while ago:
It was written for v2.35 so I don't know how much you'll have to change to get it working in the lastest version. I also remember it being a little buggy with multiline text fields. It should give you a good starting off point though. I commented most of the new functions, basic usage is like this:

Code: [Select]
_inputField = new FlxText(90, 120, 300, null, false);
_inputField.setFormat("Courier", 18, 0x000000);
_inputField.background = true;
_inputField.type = TextFieldType.INPUT;

Hope that helps.

help / Has anyone fixed FlxQuadTree yet?
« on: Wed, Aug 22, 2012 »
I'm currently working on some mobile stuff with flixel, and I've found that FlxQuadTree is causing serious performance issues. FlxG.overlap is creating a new FlxQuadTree every frame, which seems to create several new FlxQuadTrees itself, which all create multiple new FlxLists. This is causing the garbage collector to go crazy and slow the whole app down.

I tried googling the problem and came across this:
He's also noticed that FlxQuadTree is bad, but unfortunately doesn't provide a solution except to "build a persistent static grid".

Does anyone know either:
a) How to build a persistent static grid in flixel or
b) How to prevent FlxQuadTree from creating so many instances every frame?

help / Re: collide not working on right side
« on: Thu, Apr 14, 2011 »
Seem to have solved this myself. Calling refreshHulls() on the player and door after setting their x/y has apparently made the problem go away.

help / collide not working on right side
« on: Thu, Apr 14, 2011 »
I have a weird problem I can't find any help with. I have a player which has a bounding box like this:

Code: [Select]
width = 14;
height = 26;
offset.x = 10;
offset.y = 6;

and a door like this:
Code: [Select]
width = 30;
height = 23;
offset.x = 6;
offset.y = 25;

I then call
Code: [Select]

in the update function of my gamestate. This works fine until I try to make the bounding box for the door smaller. If I set the width to less than about 20 it stops working when I approach it from the right. I can walk into the door from the left or fall on it from above and it still works, but trying to walk into it from the right just results in the player walking straight past.

Anybody know what the problem is?

Pages: [1]