Skip to content

Commit 47eca23

Browse files
committed
Added refresh method and updated bones properly
1 parent ec0773a commit 47eca23

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

plugins/spine/src/gameobject/SpineGameObject.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var ComponentsTransform = require('../../../../src/gameobjects/components/Transf
1515
var ComponentsVisible = require('../../../../src/gameobjects/components/Visible');
1616
var GameObject = require('../../../../src/gameobjects/GameObject');
1717
var SpineGameObjectRender = require('./SpineGameObjectRender');
18+
var CounterClockwise = require('../../../../src/math/angle/CounterClockwise');
19+
var RadToDeg = require('../../../../src/math/RadToDeg');
1820

1921
/**
2022
* @classdesc
@@ -123,9 +125,34 @@ var SpineGameObject = new Class({
123125

124126
this.root = this.getRootBone();
125127

128+
if (this.root)
129+
{
130+
// +90 degrees to account for the difference in Spine vs. Phaser rotation
131+
this.root.rotation = RadToDeg(CounterClockwise(this.rotation)) + 90;
132+
}
133+
134+
this.state.apply(skeleton);
135+
136+
skeleton.updateCache();
137+
126138
return this.updateSize();
127139
},
128140

141+
refresh: function ()
142+
{
143+
if (this.root)
144+
{
145+
// +90 degrees to account for the difference in Spine vs. Phaser rotation
146+
this.root.rotation = RadToDeg(CounterClockwise(this.rotation)) + 90;
147+
}
148+
149+
this.updateSize();
150+
151+
this.skeleton.updateCache();
152+
153+
return this;
154+
},
155+
129156
setSize: function (width, height, offsetX, offsetY)
130157
{
131158
var skeleton = this.skeleton;

0 commit comments

Comments
 (0)