mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[as3] Fixed DeformTimeline, see #1016.
This commit is contained in:
parent
adc01ab1e4
commit
f31d98506c
Binary file not shown.
@ -35,8 +35,7 @@ package spine.animation {
|
|||||||
import spine.Skeleton;
|
import spine.Skeleton;
|
||||||
import spine.Slot;
|
import spine.Slot;
|
||||||
|
|
||||||
public class DeformTimeline extends CurveTimeline {
|
public class DeformTimeline extends CurveTimeline {
|
||||||
private static var zeros : Vector.<Number> = new Vector.<Number>(64);
|
|
||||||
public var slotIndex : int;
|
public var slotIndex : int;
|
||||||
public var frames : Vector.<Number>;
|
public var frames : Vector.<Number>;
|
||||||
public var frameVertices : Vector.<Vector.<Number>>;
|
public var frameVertices : Vector.<Vector.<Number>>;
|
||||||
@ -66,10 +65,11 @@ package spine.animation {
|
|||||||
if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment)).applyDeform(attachment)) return;
|
if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment)).applyDeform(attachment)) return;
|
||||||
|
|
||||||
var verticesArray : Vector.<Number> = slot.attachmentVertices;
|
var verticesArray : Vector.<Number> = slot.attachmentVertices;
|
||||||
|
if (verticesArray.length == 0) alpha = 1;
|
||||||
|
|
||||||
var frameVertices : Vector.<Vector.<Number>> = this.frameVertices;
|
var frameVertices : Vector.<Vector.<Number>> = this.frameVertices;
|
||||||
var vertexCount : int = frameVertices[0].length;
|
var vertexCount : int = frameVertices[0].length;
|
||||||
verticesArray.length = vertexCount;
|
var vertices : Vector.<Number>;
|
||||||
var vertices : Vector.<Number> = verticesArray;
|
|
||||||
|
|
||||||
var frames : Vector.<Number> = this.frames;
|
var frames : Vector.<Number> = this.frames;
|
||||||
var i : int;
|
var i : int;
|
||||||
@ -77,20 +77,15 @@ package spine.animation {
|
|||||||
vertexAttachment = VertexAttachment(slotAttachment);
|
vertexAttachment = VertexAttachment(slotAttachment);
|
||||||
switch (pose) {
|
switch (pose) {
|
||||||
case MixPose.setup:
|
case MixPose.setup:
|
||||||
var zeroVertices : Vector.<Number>;
|
verticesArray.length = 0;
|
||||||
if (vertexAttachment.bones == null) {
|
|
||||||
// Unweighted vertex positions (setup pose).
|
|
||||||
zeroVertices = vertexAttachment.vertices;
|
|
||||||
} else {
|
|
||||||
// Weighted deform offsets (zeros).
|
|
||||||
zeroVertices = zeros;
|
|
||||||
if (zeroVertices.length < vertexCount) zeros = zeroVertices = new Vector.<Number>(vertexCount);
|
|
||||||
}
|
|
||||||
for (i = 0; i < vertexCount; i++)
|
|
||||||
vertices[i] = zeroVertices[i];
|
|
||||||
return;
|
return;
|
||||||
case MixPose.current:
|
case MixPose.current:
|
||||||
if (alpha == 1) break;
|
if (alpha == 1) {
|
||||||
|
verticesArray.length = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
verticesArray.length = vertexCount;
|
||||||
|
vertices = verticesArray;
|
||||||
if (vertexAttachment.bones == null) {
|
if (vertexAttachment.bones == null) {
|
||||||
// Unweighted vertex positions.
|
// Unweighted vertex positions.
|
||||||
setupVertices = vertexAttachment.vertices;
|
setupVertices = vertexAttachment.vertices;
|
||||||
@ -106,6 +101,8 @@ package spine.animation {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verticesArray.length = vertexCount;
|
||||||
|
vertices = verticesArray;
|
||||||
var n : int;
|
var n : int;
|
||||||
var setup : Number, prev : Number;
|
var setup : Number, prev : Number;
|
||||||
if (time >= frames[frames.length - 1]) { // Time is after last frame.
|
if (time >= frames[frames.length - 1]) { // Time is after last frame.
|
||||||
|
|||||||
Binary file not shown.
@ -45,13 +45,13 @@ package spine.examples {
|
|||||||
import spine.starling.SkeletonAnimation;
|
import spine.starling.SkeletonAnimation;
|
||||||
|
|
||||||
public class CoinExample extends Sprite {
|
public class CoinExample extends Sprite {
|
||||||
[Embed(source = "/coin-pro.json", mimeType = "application/octet-stream")]
|
[Embed(source = "/Divico.json", mimeType = "application/octet-stream")]
|
||||||
static public const CoinJson : Class;
|
static public const CoinJson : Class;
|
||||||
|
|
||||||
[Embed(source = "/coin.atlas", mimeType = "application/octet-stream")]
|
[Embed(source = "/Divico.atlas", mimeType = "application/octet-stream")]
|
||||||
static public const CoinAtlas : Class;
|
static public const CoinAtlas : Class;
|
||||||
|
|
||||||
[Embed(source = "/coin.png")]
|
[Embed(source = "/Divico.png")]
|
||||||
static public const CoinAtlasTexture : Class;
|
static public const CoinAtlasTexture : Class;
|
||||||
private var skeleton : SkeletonAnimation;
|
private var skeleton : SkeletonAnimation;
|
||||||
|
|
||||||
@ -68,7 +68,9 @@ package spine.examples {
|
|||||||
this.y = 600;
|
this.y = 600;
|
||||||
|
|
||||||
skeleton = new SkeletonAnimation(skeletonData);
|
skeleton = new SkeletonAnimation(skeletonData);
|
||||||
skeleton.state.setAnimationByName(0, "rotate", true);
|
skeleton.state.data.defaultMix = 2;
|
||||||
|
skeleton.state.setAnimationByName(0, "airattack1", true);
|
||||||
|
skeleton.state.addAnimationByName(0, "idle", true, 3);
|
||||||
skeleton.state.timeScale = 0.5;
|
skeleton.state.timeScale = 0.5;
|
||||||
skeleton.state.update(0.25);
|
skeleton.state.update(0.25);
|
||||||
skeleton.state.apply(skeleton.skeleton);
|
skeleton.state.apply(skeleton.skeleton);
|
||||||
|
|||||||
@ -38,7 +38,7 @@ package spine.examples {
|
|||||||
private var _starling : Starling;
|
private var _starling : Starling;
|
||||||
|
|
||||||
public function Main() {
|
public function Main() {
|
||||||
_starling = new Starling(SpineboyExample, stage);
|
_starling = new Starling(CoinExample, stage);
|
||||||
_starling.enableErrorChecking = true;
|
_starling.enableErrorChecking = true;
|
||||||
_starling.showStats = true;
|
_starling.showStats = true;
|
||||||
_starling.skipUnchangedFrames = false;
|
_starling.skipUnchangedFrames = false;
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user