mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
0d443644c5
@ -1031,6 +1031,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
||||
{
|
||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name,
|
||||
path, sequence);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spRegionAttachment *region = SUB_CAST(spRegionAttachment, attachment);
|
||||
region->path = path;
|
||||
region->rotation = rotation;
|
||||
@ -1051,6 +1053,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
||||
int vertexCount = readVarint(input, 1);
|
||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||
NULL);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spVertexAttachment *vertexAttachment = SUB_CAST(spVertexAttachment, attachment);
|
||||
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
||||
&vertexAttachment->verticesCount, &vertexAttachment->vertices,
|
||||
@ -1102,6 +1106,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
||||
|
||||
{
|
||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||
mesh->path = path;
|
||||
spColor_setFromColor(&mesh->color, &color);
|
||||
@ -1151,6 +1157,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
||||
|
||||
{
|
||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||
mesh->path = path;
|
||||
spColor_setFromColor(&mesh->color, &color);
|
||||
@ -1164,6 +1172,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
||||
case SP_ATTACHMENT_PATH: {
|
||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||
NULL);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spPathAttachment *path = SUB_CAST(spPathAttachment, attachment);
|
||||
spVertexAttachment *vertexAttachment = SUPER(path);
|
||||
int vertexCount = 0;
|
||||
@ -1187,6 +1197,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
||||
case SP_ATTACHMENT_POINT: {
|
||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||
NULL);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spPointAttachment *point = SUB_CAST(spPointAttachment, attachment);
|
||||
point->rotation = readFloat(input);
|
||||
point->x = readFloat(input) * self->scale;
|
||||
@ -1203,6 +1215,8 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
||||
int vertexCount = readVarint(input, 1);
|
||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||
NULL);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spClippingAttachment *clip = SUB_CAST(spClippingAttachment, attachment);
|
||||
spVertexAttachment *vertexAttachment = SUPER(clip);
|
||||
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
||||
@ -1253,7 +1267,9 @@ spSkin *spSkeletonBinary_readSkin(spSkeletonBinary *self, _dataInput *input, int
|
||||
const char *name = readStringRef(input, skeletonData);
|
||||
spAttachment *attachment = spSkeletonBinary_readAttachment(self, input, skin, slotIndex, name, skeletonData,
|
||||
nonessential);
|
||||
if (attachment) spSkin_setAttachment(skin, slotIndex, name, attachment);
|
||||
if (!attachment)
|
||||
return NULL;
|
||||
spSkin_setAttachment(skin, slotIndex, name, attachment);
|
||||
}
|
||||
}
|
||||
return skin;
|
||||
@ -1508,6 +1524,11 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
|
||||
|
||||
/* Default skin. */
|
||||
skeletonData->defaultSkin = spSkeletonBinary_readSkin(self, input, -1, skeletonData, nonessential);
|
||||
if (self->attachmentLoader->error1) {
|
||||
spSkeletonData_dispose(skeletonData);
|
||||
_spSkeletonBinary_setError(self, self->attachmentLoader->error1, self->attachmentLoader->error2);
|
||||
return NULL;
|
||||
}
|
||||
skeletonData->skinsCount = readVarint(input, 1);
|
||||
|
||||
if (skeletonData->defaultSkin)
|
||||
@ -1520,7 +1541,13 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
|
||||
|
||||
/* Skins. */
|
||||
for (i = skeletonData->defaultSkin ? 1 : 0; i < skeletonData->skinsCount; ++i) {
|
||||
skeletonData->skins[i] = spSkeletonBinary_readSkin(self, input, 0, skeletonData, nonessential);
|
||||
spSkin *skin = spSkeletonBinary_readSkin(self, input, 0, skeletonData, nonessential);
|
||||
if (self->attachmentLoader->error1) {
|
||||
spSkeletonData_dispose(skeletonData);
|
||||
_spSkeletonBinary_setError(self, self->attachmentLoader->error1, self->attachmentLoader->error2);
|
||||
return NULL;
|
||||
}
|
||||
skeletonData->skins[i] = skin;
|
||||
}
|
||||
|
||||
/* Linked meshes. */
|
||||
@ -1575,6 +1602,7 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
|
||||
if (!animation) {
|
||||
FREE(input);
|
||||
spSkeletonData_dispose(skeletonData);
|
||||
_spSkeletonBinary_setError(self, "Animation corrupted: ", name);
|
||||
return NULL;
|
||||
}
|
||||
skeletonData->animations[i] = animation;
|
||||
|
||||
@ -984,8 +984,8 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
|
||||
|
||||
skeleton = Json_getItem(root, "skeleton");
|
||||
if (skeleton) {
|
||||
MALLOC_STR(skeletonData->hash, Json_getString(skeleton, "hash", 0));
|
||||
MALLOC_STR(skeletonData->version, Json_getString(skeleton, "spine", 0));
|
||||
MALLOC_STR(skeletonData->hash, Json_getString(skeleton, "hash", "0"));
|
||||
MALLOC_STR(skeletonData->version, Json_getString(skeleton, "spine", "0"));
|
||||
if (!string_starts_with(skeletonData->version, SPINE_VERSION_STRING)) {
|
||||
char errorMsg[255];
|
||||
sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->version, SPINE_VERSION_STRING);
|
||||
|
||||
@ -89,12 +89,12 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro
|
||||
constructor (scene: Phaser.Scene, private plugin: SpinePlugin, x: number, y: number, dataKey: string, atlasKey: string, public boundsProvider: SpineGameObjectBoundsProvider = new SetupPoseBoundsProvider()) {
|
||||
super(scene, SPINE_GAME_OBJECT_TYPE);
|
||||
this.setPosition(x, y);
|
||||
|
||||
|
||||
this.premultipliedAlpha = this.plugin.isAtlasPremultiplied(atlasKey);
|
||||
this.skeleton = this.plugin.createSkeleton(dataKey, atlasKey);
|
||||
this.animationStateData = new AnimationStateData(this.skeleton.data);
|
||||
this.animationState = new AnimationState(this.animationStateData);
|
||||
this.updateSize();
|
||||
this.updateSize();
|
||||
}
|
||||
|
||||
public get displayOriginX () {
|
||||
@ -178,7 +178,7 @@ export class SpineGameObject extends ComputedSizeMixin(DepthMixin(FlipMixin(Scro
|
||||
this.skeleton.updateWorldTransform();
|
||||
}
|
||||
|
||||
preDestroy () {
|
||||
preDestroy () {
|
||||
// FIXME tear down any event emitters
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ export class SpinePlugin extends Phaser.Plugins.ScenePlugin {
|
||||
|
||||
let makeSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, config: SpineGameObjectConfig, addToScene: boolean) {
|
||||
let x = config.x ? config.x : 0;
|
||||
let y = config.y ? config.y : 0;
|
||||
let y = config.y ? config.y : 0;
|
||||
let boundsProvider = config.boundsProvider ? config.boundsProvider : undefined;
|
||||
let gameObject = new SpineGameObject(this.scene, self, x, y, config.dataKey, config.atlasKey, boundsProvider);
|
||||
if (addToScene !== undefined) {
|
||||
|
||||
@ -11,21 +11,21 @@ import { SpineGameObjectConfig, SpinePlugin } from "./SpinePlugin";
|
||||
import { SpineGameObject, SpineGameObjectBoundsProvider } from "./SpineGameObject";
|
||||
|
||||
declare global {
|
||||
namespace Phaser.Loader {
|
||||
export interface LoaderPlugin {
|
||||
spineJson(key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||
spineBinary(key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||
spineAtlas(key: string, url: string, premultipliedAlpha?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||
}
|
||||
}
|
||||
namespace Phaser.Loader {
|
||||
export interface LoaderPlugin {
|
||||
spineJson (key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||
spineBinary (key: string, url: string, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||
spineAtlas (key: string, url: string, premultipliedAlpha?: boolean, xhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Phaser.GameObjects {
|
||||
export interface GameObjectFactory {
|
||||
spine(x: number, y: number, dataKey: string, atlasKey: string, boundsProvider?: SpineGameObjectBoundsProvider): SpineGameObject;
|
||||
}
|
||||
namespace Phaser.GameObjects {
|
||||
export interface GameObjectFactory {
|
||||
spine (x: number, y: number, dataKey: string, atlasKey: string, boundsProvider?: SpineGameObjectBoundsProvider): SpineGameObject;
|
||||
}
|
||||
|
||||
export interface GameObjectCreator {
|
||||
spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject;
|
||||
}
|
||||
}
|
||||
export interface GameObjectCreator {
|
||||
spine (config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user