4.0 Upgrade page suggestions

68 views
Skip to first unread message

Shaun Michael K. Stone

unread,
Feb 24, 2016, 5:59:33 AM2/24/16
to haxef...@googlegroups.com
Hi, great work Haxeflixel team!!

 I have created a new branch and currently going through the upgrade. I noticed a few things missing:

1. FlxCollisionType ? Where is this now.

2. SparrowData I have noticed is now FlxAtlasFrames. As I use Sparrow data I would call: FlxAtlasFrames.fromSparrow  I could imagine atlases are prevalent for user projects so would be worth having a section for this near the loadGraphicFromTexture method reference.
3. No more interfaces namespace so cannot find IFlxParticle so remove this reference as this has been moved under the FlxParticle class file.
4. I had a situation where I needed to extract a single method image from an atlas to then use for FlxBackdrop. These now do not exist.

import flixel.util.loaders.TextureAtlasFrame;
import flixel.util.loaders.TexturePackerXMLData;
import flixel.util.loaders.TextureRegion;

When using FlxBackdrop I did it like this when extracting a frame from an atlas.
image = new FlxBackdrop(
FlxGraphic.fromFrame(textureAtlas.getByName('image')),
2,
0, 
true, 
false
); 
add(image);

5. 
class Butterflies extends FlxGroup<FlxEmitter> // Invalid number of type parameters for flixel.group.FlxGroup

Had to remove so it is just FlxGroup.

6. It seems recycling now requires a factory function as this won't run any more. 

var attributesPassedToConstructor:Attributes = {};
var gameObject:GameObject = gameObjectsGroup.recycle(GameObject, [attributesPassedToConstructor]);

It used to be:

public inline function recycle(?ObjectClass:Class<T>, ?ContructorArgs:Array<Dynamic>, Force:Bool = false):FlxSprite
Now it is:
public function recycle(?ObjectClass:Class<T>, ?ObjectFactory:Void->T, Force:Bool = false, Revive:Bool = true):T

In the end to get it working I did this. Had to cast as it returns a FlxBasic for some reason.

var gameObject:GameObject = cast(gameObjectsGroup.recycle(GameObject, function() {
return Type.createInstance(GameObject, [attributesPassedToConstructor]);
}), GameObject);

7. This is just my opinion but I always think when new arguments are added to a method they should be open for extension and closed to modification. In other words the new reversed argument should've went at the end of the animation.play method.

 play(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void

8. No more: FlxSpriteUtil.screenCenter() I used this a lot. You call this directly on the sprite. sprite.screenCenter();

9. setYSpeed and setXSpeed on particles - I think now uses particle.acceleration ?

10. It seems that the sprite origin used to be center by default and is now top left. It always defaulted to top left, but because I used to use loadGraphic from texture it centered origin and reset frame size.

Will add to this post as I go.
Thanks!
Reply all
Reply to author
Forward
0 new messages