Davide 7f2e4c1df7
[haxe] Support for HaxeFlixel (#2764)
* [haxe] Flixel support

* [haxe][flixel] WIP fix alpha and color tinting not working on meshes.

* [haxe][flixel] Added most of examples - Color/alpha is broken on flixel for meshes.

* [haxe][flixel] Flixel color bug example

* [haxe][flixel] Add same example of starling to Flixel.

* [haxe][flixel] Fix rotation for clipped attachments.

* [haxe][flixel] Minor modifications to avoid warning on flixel 6.0.0.

* [haxe] Updated readme.

* [haxe][flixel] Remove unused assets.

* [haxe] Removed useless flipX/flipY on core Skeleton.hx.
2025-02-24 10:44:05 +01:00

39 lines
1.2 KiB
Haxe

package flixelExamples;
import spine.Skin;
import flixel.ui.FlxButton;
import flixel.FlxG;
import spine.flixel.SkeletonSprite;
import spine.flixel.FlixelTextureLoader;
import flixel.FlxState;
import openfl.utils.Assets;
import spine.SkeletonData;
import spine.animation.AnimationStateData;
import spine.atlas.TextureAtlas;
class TankExample extends FlxState {
var loadBinary = true;
override public function create():Void {
FlxG.cameras.bgColor = 0xffa1b2b0;
var button = new FlxButton(0, 0, "Next scene", () -> FlxG.switchState(() -> new VineExample()));
button.setPosition(FlxG.width * .75, FlxG.height / 10);
add(button);
var atlas = new TextureAtlas(Assets.getText("assets/tank.atlas"), new FlixelTextureLoader("assets/tank.atlas"));
var data = SkeletonData.from(loadBinary ? Assets.getBytes("assets/tank-pro.skel") : Assets.getText("assets/tank-pro.json"), atlas, .125);
var animationStateData = new AnimationStateData(data);
animationStateData.defaultMix = 0.25;
var skeletonSprite = new SkeletonSprite(data, animationStateData);
var animation = skeletonSprite.state.setAnimationByName(0, "drive", true).animation;
skeletonSprite.setBoundingBox(animation);
skeletonSprite.screenCenter();
add(skeletonSprite);
super.create();
}
}