Spine skeletal animation

Spine is a 2D animation software tailored specifically for software and game developers. Animators, original artists, and engineers work together to give life to your game. Using Spine skeletal animation can achieve some richer effects, which can better reduce memory usage compared to sprite animation. Spine is a paid software, please use it after purchase, Spine official website: http://zh.esotericsoftware.com/. The currently supported Spine version is: 3.6 / 3.8 / 4.0, you can click here see how to set

-https://eva.js.org/playground/#/spine

Install

The currently supported Spine version is: 3.6 / 3.8 / 4.0, You can select npm package by version.

  • 3.6 @eva/plugin-renderer-spine
  • 3.8 @eva/plugin-renderer-spine38
  • 4.0 @eva/plugin-renderer-spine40

With NPM

  1. npm i @eva/plugin-renderer @eva/plugin-renderer-spine40

In Browser

  1. <script src="https://unpkg.com/@eva/plugin-renderer-spine@1.2.x/dist/EVA.plugin.renderer.spine.min.js"></script>

Usage

  1. import {Game, GameObject, resource, RESOURCE_TYPE} from '@eva/eva.js'
  2. import {RendererSystem} from '@eva/plugin-renderer'
  3. import {Spine, SpineSystem} from '@eva/plugin-renderer-spine'
  4. resource.addResource([
  5. {
  6. name:'anim',
  7. type:'SPINE',
  8. src: {
  9. ske: {
  10. type:'json',
  11. url:'https://pages.tmall.com/wow/eva/b5fdf74313d5ff2609ab82f6b6fd83e6.json'
  12. },
  13. atlas: {
  14. type:'atlas',
  15. url:'https://pages.tmall.com/wow/eva/b8597f298a5d6fe47095d43ef03210d4.atlas'
  16. },
  17. image: {
  18. type:'png',
  19. url:'https://gw.alicdn.com/tfs/TB1YHC8Vxz1gK0jSZSgXXavwpXa-711-711.png'
  20. }
  21. }
  22. }
  23. ])
  24. const game = new Game({
  25. systems: [
  26. new RendererSystem({
  27. canvas: document.querySelector('#canvas'),
  28. width: 750,
  29. height: 1000
  30. }),
  31. new SpineSystem()
  32. ],
  33. autoStart: true,
  34. frameRate: 60
  35. })
  36. game.scene.transform.size = {
  37. width: 750,
  38. height: 1000
  39. }
  40. const gameObject = new GameObject('spine', {
  41. anchor: {
  42. x: 0.5,
  43. y: 0.5
  44. },
  45. scale: {
  46. x: 0.5,
  47. y: 0.5
  48. }
  49. })
  50. const spine = new Spine({ resource:'anim', animationName:'idle' })
  51. gameObject.addComponent(spine)
  52. spine.on('complete', e => {
  53. console.log('Animation playback ended', e.name)
  54. })
  55. spine.play('idle')
  56. game.scene.addChild(gameObject)

Options

resource string

Resource Name

animationName string

Animation name

Methods

play(name?: string, loop?: boolean)

Play animation

-name action name -loop Whether to play in a loop

stop()

Stop play