mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 06:14:53 +08:00
* [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.
39 lines
1.2 KiB
Haxe
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();
|
|
}
|
|
}
|