-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[haxe][flixel] WIP fix alpha and color tinting not working on meshes.
- Loading branch information
Showing
10 changed files
with
215 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
skeleton.png | ||
size:404,404 | ||
filter:Linear,Linear | ||
pma:true | ||
square | ||
bounds:2,2,400,400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"skeleton":{"hash":"gAzm+5Vz+z4","spine":"4.2.33","x":-320.5,"y":-381.5,"width":1036,"height":1194,"images":"./images","audio":"./audio"},"bones":[{"name":"root"}],"slots":[{"name":"square","bone":"root","attachment":"square"},{"name":"square2","bone":"root","attachment":"square"},{"name":"square3","bone":"root","attachment":"square"},{"name":"square4","bone":"root","color":"ff7676ff","attachment":"square"},{"name":"square5","bone":"root","attachment":"square"},{"name":"square6","bone":"root","attachment":"square"}],"skins":[{"name":"default","attachments":{"square":{"square":{"x":-2.5,"y":-5.5,"width":400,"height":400}},"square2":{"square":{"color":"ff0000ff","x":227.5,"y":160.5,"width":400,"height":400}},"square3":{"square":{"x":397.5,"y":306.5,"width":400,"height":400}},"square4":{"square":{"x":199.5,"y":612.5,"width":400,"height":400}},"square5":{"square":{"x":-120.5,"y":442.5,"width":400,"height":400}},"square6":{"square":{"color":"f700c0ff","x":515.5,"y":-181.5,"width":400,"height":400}}}}],"animations":{"animation":{}}} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
spine-haxe/example/src/flixelExamples/MixAndMatchExample.hx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
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 MixAndMatchExample extends FlxState { | ||
var loadBinary = false; | ||
// var loadBinary = true; | ||
|
||
var skeletonSprite:SkeletonSprite; | ||
override public function create():Void { | ||
var button = new FlxButton(0, 0, "Next scene", () -> FlxG.switchState(new BasicExample())); | ||
button.setPosition(FlxG.width * .75, FlxG.height / 10); | ||
add(button); | ||
|
||
// var atlas = new TextureAtlas(Assets.getText("assets/export/skeleton.atlas"), new FlixelTextureLoader("assets/export/skeleton.atlas")); | ||
// var data = SkeletonData.from(loadBinary ? Assets.getBytes("assets/export/skeleton.skel") : Assets.getText("assets/export/skeleton.json"), atlas, .5); | ||
|
||
var atlas = new TextureAtlas(Assets.getText("assets/mix-and-match.atlas"), new FlixelTextureLoader("assets/mix-and-match.atlas")); | ||
var data = SkeletonData.from(loadBinary ? Assets.getBytes("assets/mix-and-match-pro.skel") : Assets.getText("assets/mix-and-match-pro.json"), atlas, .5); | ||
var animationStateData = new AnimationStateData(data); | ||
animationStateData.defaultMix = 0.25; | ||
|
||
skeletonSprite = new SkeletonSprite(data, animationStateData); | ||
// var customSkin = new Skin("custom"); | ||
// var skinBase = data.findSkin("skin-base"); | ||
// customSkin.addSkin(skinBase); | ||
// customSkin.addSkin(data.findSkin("nose/short")); | ||
// customSkin.addSkin(data.findSkin("eyelids/girly")); | ||
// customSkin.addSkin(data.findSkin("eyes/violet")); | ||
// customSkin.addSkin(data.findSkin("hair/brown")); | ||
// customSkin.addSkin(data.findSkin("clothes/hoodie-orange")); | ||
// customSkin.addSkin(data.findSkin("legs/pants-jeans")); | ||
// customSkin.addSkin(data.findSkin("accessories/bag")); | ||
// customSkin.addSkin(data.findSkin("accessories/hat-red-yellow")); | ||
// skeletonSprite.skeleton.skin = customSkin; | ||
|
||
camera.zoom = .5; | ||
skeletonSprite.skeleton.skinName = "full-skins/girl"; | ||
skeletonSprite.setBoundingBox(); | ||
|
||
skeletonSprite.afterUpdateWorldTransforms = s -> { | ||
for(slot in s.skeleton.slots) { | ||
if (slot.data.name != "hair-patch") { | ||
// slot.attachment = null; | ||
} | ||
} | ||
} | ||
|
||
// skeletonSprite.y -=300; | ||
|
||
skeletonSprite.screenCenter(); | ||
// skeletonSprite.state.setAnimationByName(0, "dance", true); | ||
add(skeletonSprite); | ||
|
||
// FlxG.debugger.visible = !FlxG.debugger.visible; | ||
// FlxG.debugger.track(skeletonSprite); | ||
// FlxG.debugger.track(camera); | ||
FlxG.debugger.drawDebug = true; | ||
super.create(); | ||
} | ||
|
||
override public function update(elapsed:Float):Void | ||
{ | ||
if (FlxG.keys.anyPressed([RIGHT])) { | ||
skeletonSprite.x += 15; | ||
} | ||
if (FlxG.keys.anyPressed([LEFT])) { | ||
skeletonSprite.x -= 15; | ||
} | ||
if (FlxG.keys.anyPressed([UP])) { | ||
skeletonSprite.y -= 15; | ||
} | ||
if (FlxG.keys.anyPressed([DOWN])) { | ||
skeletonSprite.y += 15; | ||
} | ||
|
||
super.update(elapsed); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package flixelExamples; | ||
|
||
|
||
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 SequenceExample extends FlxState { | ||
var loadBinary = true; | ||
|
||
var skeletonSprite:SkeletonSprite; | ||
override public function create():Void { | ||
var button = new FlxButton(0, 0, "Next scene", () -> FlxG.switchState(new MixAndMatchExample())); | ||
button.setPosition(FlxG.width * .75, FlxG.height / 10); | ||
add(button); | ||
|
||
var atlas = new TextureAtlas(Assets.getText("assets/dragon.atlas"), new FlixelTextureLoader("assets/dragon.atlas")); | ||
var skeletondata = SkeletonData.from(loadBinary ? Assets.getBytes("assets/dragon-ess.skel") : Assets.getText("assets/dragon-.json"), atlas, .5); | ||
var animationStateData = new AnimationStateData(skeletondata); | ||
animationStateData.defaultMix = 0.25; | ||
|
||
skeletonSprite = new SkeletonSprite(skeletondata, animationStateData); | ||
skeletonSprite.screenCenter(); | ||
skeletonSprite.y -= 100; | ||
|
||
skeletonSprite.state.setAnimationByName(0, "flying", true); | ||
FlxG.debugger.visible = !FlxG.debugger.visible; | ||
FlxG.debugger.track(skeletonSprite); | ||
add(skeletonSprite); | ||
super.create(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters