azerion / phaser-spine

A plugin for Phaser 2 that adds Spine support
MIT License
121 stars 57 forks source link

Upgrade Spine runtime to spine-ts #11

Closed AleBles closed 6 years ago

AleBles commented 7 years ago

blogpost: http://esotericsoftware.com/blog/spine-ts-released

repo: https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-ts

shibekin69 commented 7 years ago

Awesome! Pretty good plugin. I thought that spine wasn't supported in Phaser before stumbling onto that blogpost, and then this plugin. How's the mobile performance of Phaser + Spine + Intel XDK on a mobile phone for you so far?

AleBles commented 7 years ago

It's pretty decent. We've released only one game with Spine assets, and the performance is not bad at all. There's always some room for improvement, but it was definitely playable!

shibekin69 commented 7 years ago

I've given it a test run as well. On an octacore Snadragon 615 CPU, I take it it does about 30-40fps consistently without apparent stuttering while displaying the spineboy and raptor spine objects (without scaling them down) at the same time. Speaking of which, how do I destroy spine objects? I currently assigned them to one or two groups, then when I destroy them, I do:

objspinegroups[spinekey].destroy(); delete objspinegroups[spinekey];

It does remove them, but I'm thinking that removing them while they're still animating will still have the plugin compute for their animations despite them being removed visually. Is this the case?

And would you know if setting:

game.tweens.frameBased = true;

has an effect on spine's animation's timing? Because from what I noticed with Phaser, sometimes, when you need multiple tween animations using the built-in tweener to sync with each other, the frameBased timing must be enabled with a "visual performance" trade-off. And if it's disabled, the game's tween transitions appears smoother, but with the risk of going out of sync with each other. This "visual performance" degradation is more apparent in mobile phones.

AleBles commented 7 years ago

the Spine object is an extend Phaser.Group so it has a destroy() method like everything else. It could be possible that there is a leak somewhere in destroying them, I didn't add any extra logic there.

As for the tween stuff, spine simply only updates x/y/rotation values based on what is done in the runtime. There are no Phaser Tweens active, so settings tweens to frameBased should have no impact on the Spine animation

shibekin69 commented 7 years ago

Ah ok, so spine's animation is separate and doesn't use Phaser's built-in tweener in any way no?

And the destroy() function should clear up any spine animation on stage and/or running, freeing up memory and cpu as it should, correct?

AleBles commented 6 years ago

This gist of it is done in the spine-ts branch, all the lingering issues will be picked up seperatly and we have the project page now to track progress