@@ -13,7 +13,9 @@ var ComponentsFlip = require('../../../../src/gameobjects/components/Flip');
1313var ComponentsScrollFactor = require ( '../../../../src/gameobjects/components/ScrollFactor' ) ;
1414var ComponentsTransform = require ( '../../../../src/gameobjects/components/Transform' ) ;
1515var ComponentsVisible = require ( '../../../../src/gameobjects/components/Visible' ) ;
16+ var CounterClockwise = require ( '../../../../src/math/angle/CounterClockwise' ) ;
1617var GameObject = require ( '../../../../src/gameobjects/GameObject' ) ;
18+ var RadToDeg = require ( '../../../../src/math/RadToDeg' ) ;
1719var SpineGameObjectRender = require ( './SpineGameObjectRender' ) ;
1820
1921/**
@@ -132,34 +134,37 @@ var SpineGameObject = new Class({
132134 this . setAnimation ( 0 , animationName , loop ) ;
133135 }
134136
137+ var renderer = this . scene . sys . renderer ;
138+
139+ var height = renderer . height ;
140+
135141 skeleton . x = this . x ;
136- skeleton . y = 600 - this . y ;
142+ skeleton . y = height - this . y ;
137143 skeleton . scaleX = this . scaleX ;
138144 skeleton . scaleY = this . scaleY ;
139145
140- skeleton . updateWorldTransform ( ) ;
141-
142146 this . skeleton = skeleton ;
143147
144148 this . root = this . getRootBone ( ) ;
149+
150+ if ( this . root )
151+ {
152+ // - 90 degrees to account for the difference in Spine vs. Phaser rotation
153+ this . root . rotation = RadToDeg ( CounterClockwise ( this . rotation - 1.5707963267948966 ) ) ;
154+ }
145155
146- var b = this . getBounds ( ) ;
147-
148- // var w = this.skeletonData.width;
149- // var h = this.skeletonData.height;
156+ skeleton . updateWorldTransform ( ) ;
150157
151- // this.width = w;
152- // this.height = h;
158+ var b = this . getBounds ( ) ;
153159
154- // this.displayOriginX = w / 2 ;
155- // this.displayOriginY = h ;
160+ var sx = 1 / this . scaleX ;
161+ var sy = 1 / this . scaleY ;
156162
157- this . width = b . size . x ;
158- this . height = b . size . y ;
159- this . displayOriginX = this . width / 2 ;
160- this . displayOriginY = this . height / 2 ;
163+ this . width = b . size . x * sx ;
164+ this . height = b . size . y * sy ;
161165
162- console . log ( b . offset , b . size ) ;
166+ this . displayOriginX = ( this . x - b . offset . x ) * sx ;
167+ this . displayOriginY = this . y - ( height - ( this . height + b . offset . y ) ) ;
163168
164169 return this ;
165170 } ,
0 commit comments