@@ -317,7 +317,7 @@ func applyRenderOffset(p *SpriteImpl, cx, cy *float64) {
317317 * cy = * cy + y
318318}
319319
320- func registerAnimToEngine (spriteName string , animName string , animCfg * aniConfig , costumes []* costume , isCostumeSet bool ) {
320+ func registerAnimToEngine (spriteName string , animName string , animCfg * aniConfig , costumes []* costume , isCostumeSet bool , applyCustumeOffset2Animation bool ) {
321321 // TODO(jiepengtan): here we should optimize the implementation, it's better to use json to map, avoid manually writing parsing code
322322 sb := strings.Builder {}
323323 from , to := animCfg .IFrameFrom , animCfg .IFrameTo
@@ -356,10 +356,14 @@ func registerAnimToEngine(spriteName string, animName string, animCfg *aniConfig
356356 if strings .Contains (assetPath , splitTag ) {
357357 panic ("assetPath is invalid, should not contains " + splitTag + " " + costumes [i ].path )
358358 }
359- costume := costumes [i ]
360359 sb .WriteString (assetPath )
361- halfSize := mathf .Vec2 .Mulf (costume .imageSize , 0.5 )
362- sb .WriteString (splitTag + fmt .Sprintf ("%f,%f" , costume .center .X - halfSize .X , - costume .center .Y + halfSize .Y ))
360+ if applyCustumeOffset2Animation {
361+ costume := costumes [i ]
362+ halfSize := mathf .Vec2 .Mulf (costume .imageSize , 0.5 )
363+ sb .WriteString (splitTag + fmt .Sprintf ("%f,%f" , costume .center .X - halfSize .X , - costume .center .Y + halfSize .Y ))
364+ } else {
365+ sb .WriteString (splitTag + fmt .Sprintf ("%f,%f" , 0.0 , 0.0 ))
366+ }
363367 if i != to {
364368 sb .WriteString (";" )
365369 }
0 commit comments