spine-phaser released
Exciting news! I'm a n00b with Spine so likely this is a very simple and obvious questions but I can't figure out so any help is highly appreciated
(I tried googling and this forum so far): Is a Spine editor with major.minor version 4.2 needed to use spine-phaser 4.2.15? (and is this the version being announced? Apologies I'm so lost)
The docs say to do version matching but I can't figure out how to install the Spine Editor with major.minor of 4.2 (the changelog seems to indicate it is not released yet?)
Potentially a separate Issue:
I ask because we have an Spine project from version 3.8, which I already opened and converted to 4.1, and it does load with no problem on Phaser, but I can't for the life of me get it to render! In the Chrome Developer tools I can see the SpineGameObject has height/width of -Infinity.
I'm trying to do the version matching per the docs (link above), this Spine forum post, and this phaser discourse ticket but somehow I can't figure it out.
I also tried installing in my project spine-phaser 4.1.33 given I was able to get and export from Spine editor 4.1.23, but I had the same issue described above (phaser loads the Spine with not issue, but I see nothing rendered). I am able to get the sample spineboy working (even though its skeleton say 4.1.17 and as noted above I'm using spine-phaser 4.2.15) but not this other project asset that I converted from 3.8 to 4.1.
Thank you so much for your time and help!
Any 4.2.xx version works with the 4.2 runtime. The patch
part of the major.minor.patch
version number can differ. In general you should use the highest patch version available for the major.minor
version you are using.
Hi Nate thanks for the reply! How can I use the Spine editor with major 4 and minor 2? I can't select it from the list (please see 1st screenshot below), and if I select "Other" and type any of 4.2, 4.2.00, or 4.2.00-beta, I get an error stating those versions don't exists (please see 2nd screenshot below)
Ooooh, there is no 4.2 editor version released yet. Sorry I didn't notice previously. spine-phaser is in the 4.1 runtimes:
https://github.com/EsotericSoftware/spine-runtimes/tree/4.1/spine-ts/spine-phaser
You can use any 4.1 editor version to export and use the 4.1 spine-phaser runtime.
Hi Nate, thanks again for the prompt reply! I also tried using Spine editor 4.1.23, exporting my project, and using spine-phaser 4.1.33, but I get the same issue described on the post: phaser loads the Spine with not issue, but I see nothing rendered. In case useful info: In the Chrome Developer tools I can see the SpineGameObject has height/width of -Infinity. Any thoughts on what to look for, how to debug, typical gotchas?
Ok I solved my problem: the issue was that the default skin would show nothing. By applying a skin after generating the SpineGameObject in Phaser, then the asset did show up on the canvas!
Couple gotchas that made this confusing:
1) The SpineGameObject shows -Infinity on width and height, even when I can now see the asset on the game! I'm not sure what does this mean?
2) The online docs for 4.1 runtime show a setSkin function that fails on Phaser, it seems to not exists? Instead, I had to use setSkinByName (which I got to learn existed from VSCode autocomplete magic)
Leaving the solution in case anyone has similar issue / misunderstanding in the future.
Also if anyone knows any insights into questions (1) and (2) above, it would be great to know the answers to deepen my knowledge of Spine, which clearly is very shallow...
Thanks!
Mario can help with 1. For 2, remember the API docs are applicable to all runtimes. Some runtimes have slightly different method names because the programming languages they use don't support method overloading.
@meirmsn sorry for the late reply, I was on vacation!
When you create a SpineGameObject
it needs to somehow calculate its own width and height. By default, the object will do so based by calculating a bounding rectangle that encloses all attachments visible in the setup pose of the skeleton. Those are the attachments of the default skin.
As I understand, your skeleton has an empty default skin, so there aren't any attachments on it without setting a skin? In that case, the bounds can not be calculated, so you get infinite width and height. I've just fixed this up so that in this case, width and height will be 0 instead.
If you do not have visible attachments in the setup pose, you can pass a BoundsProvider
to the SpineGameObject
constructor. Here's how that looks like with our mix-and-match example, which also has an empty default skin:
const mixAndMatch = this.add.spine(400, 500, 'mix-and-match-data', "mix-and-match-atlas", new spine.SkinsAndAnimationBoundsProvider(null, ["full-skins/girl"]));
When the SpineGameObject
calculates its bounds, it will ask the SkinsAndAnimationBoundsProvider
to do the actual calculation. The SkinsAndAnimationBoundsProvider
is given a skin called full-skin/girl
, from which it will set the attachments and then calculate the bounds. The width and height of the SpineGameObject
will then be those found in the bounds.
You can do the same for your use case: just use a SkinsAndAnimationBoundsProvider
and give it a list of skins which it should set on the skeleton to calculate the bounds with.
Hi!
I'm trying the Phaser runtime. I did run the typescript example and it works great. It also auto-completes well in VS Code.
However, I don't find the typescript definitions for common typescript coding. There are ES module typescript definitions, but many users are coding Phaser games without ES modules.
arianfornaris Created a separate thread for it: https://esotericsoftware.com/forum/d/24599-missing-type-definitions-dts-files-for-iief-build