mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[haxe][flixel] Add bounds property and removed boundsX and boundsY.
This commit is contained in:
parent
eae2e7d5a2
commit
0e42469d36
@ -29,6 +29,7 @@
|
||||
|
||||
package flixelExamples;
|
||||
|
||||
import spine.boundsprovider.SkinsAndAnimationBoundsProvider;
|
||||
import flixel.ui.FlxButton;
|
||||
import flixel.FlxG;
|
||||
import spine.flixel.SkeletonSprite;
|
||||
@ -56,8 +57,8 @@ class BasicExample extends FlxState {
|
||||
var animationStateData = new AnimationStateData(skeletondata);
|
||||
animationStateData.defaultMix = 0.25;
|
||||
|
||||
skeletonSprite = new SkeletonSprite(skeletondata, animationStateData);
|
||||
// skeletonSprite.state.setAnimationByName(0, "walk", true);
|
||||
skeletonSprite = new SkeletonSprite(skeletondata, animationStateData, new SkinsAndAnimationBoundsProvider("walk", null));
|
||||
skeletonSprite.state.setAnimationByName(0, "walk", true);
|
||||
skeletonSprite.screenCenter();
|
||||
add(skeletonSprite);
|
||||
|
||||
|
||||
@ -66,11 +66,13 @@ class BoundsProviderExample extends FlxState {
|
||||
skeletonSpriteClipping.screenCenter();
|
||||
skeletonSpriteClipping.x = FlxG.width / 4;
|
||||
add(skeletonSpriteClipping);
|
||||
|
||||
var bounds = skeletonSpriteClipping.bounds;
|
||||
var textClipping = new FlxText();
|
||||
textClipping.text = "Bounds with clipping";
|
||||
textClipping.size = 12;
|
||||
textClipping.x = skeletonSpriteClipping.boundsX + skeletonSpriteClipping.width / 2 - textClipping.width / 2;
|
||||
textClipping.y = skeletonSpriteClipping.boundsY + skeletonSpriteClipping.height + 20;
|
||||
textClipping.x = bounds.x + skeletonSpriteClipping.width / 2 - textClipping.width / 2;
|
||||
textClipping.y = bounds.y + skeletonSpriteClipping.height + 20;
|
||||
textClipping.setBorderStyle(FlxTextBorderStyle.OUTLINE, FlxColor.RED, 2);
|
||||
add(textClipping);
|
||||
|
||||
@ -79,11 +81,13 @@ class BoundsProviderExample extends FlxState {
|
||||
skeletonSpriteNoClipping.screenCenter();
|
||||
skeletonSpriteNoClipping.x = FlxG.width / 4 * 3;
|
||||
add(skeletonSpriteNoClipping);
|
||||
|
||||
var bounds = skeletonSpriteNoClipping.bounds;
|
||||
var textNoClipping = new FlxText();
|
||||
textNoClipping.text = "Bounds without clipping";
|
||||
textNoClipping.size = 12;
|
||||
textNoClipping.x = skeletonSpriteNoClipping.boundsX + skeletonSpriteNoClipping.width / 2 - textNoClipping.width / 2;
|
||||
textNoClipping.y = skeletonSpriteNoClipping.boundsY + skeletonSpriteNoClipping.height + 20;
|
||||
textNoClipping.x = bounds.x + skeletonSpriteNoClipping.width / 2 - textNoClipping.width / 2;
|
||||
textNoClipping.y = bounds.y + skeletonSpriteNoClipping.height + 20;
|
||||
textNoClipping.setBorderStyle(FlxTextBorderStyle.OUTLINE, FlxColor.RED, 2);
|
||||
add(textNoClipping);
|
||||
|
||||
|
||||
@ -81,8 +81,9 @@ class SkeletonSprite extends FlxTypedGroup<FlxObject> {
|
||||
public var y(default, set) = 0.;
|
||||
public var width(get, set):Float;
|
||||
public var height(get, set):Float;
|
||||
public var boundsX(get, never):Float;
|
||||
public var boundsY(get, never):Float;
|
||||
|
||||
/** The bounds of the gameobject. */
|
||||
public var bounds(get, never):Rectangle;
|
||||
|
||||
@:isVar
|
||||
public var scale(never, set):FlxPoint;
|
||||
@ -403,12 +404,13 @@ class SkeletonSprite extends FlxTypedGroup<FlxObject> {
|
||||
return __bounds.height;
|
||||
}
|
||||
|
||||
function get_boundsX():Float {
|
||||
return __objectBounds.x;
|
||||
}
|
||||
|
||||
function get_boundsY():Float {
|
||||
return __objectBounds.y;
|
||||
function get_bounds():Rectangle {
|
||||
var bounds = new Rectangle();
|
||||
bounds.x = __objectBounds.x;
|
||||
bounds.y = __objectBounds.y;
|
||||
bounds.width = __objectBounds.width;
|
||||
bounds.height = __objectBounds.height;
|
||||
return bounds;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user