Skip to content

Commit

Permalink
[as3][starling] Fixed TexturePacker trimming support. Thanks @evilber…
Browse files Browse the repository at this point in the history
…t103! Closes #948
  • Loading branch information
badlogic committed Jul 19, 2017
1 parent 4a69af1 commit 262bc26
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Binary file modified spine-as3/spine-as3-example/lib/spine-as3.swc
Binary file not shown.
40 changes: 20 additions & 20 deletions spine-as3/spine-as3/src/spine/attachments/RegionAttachment.as
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,29 @@ package spine.attachments {
public function updateOffset() : void {
var regionScaleX : Number = width / regionOriginalWidth * scaleX;
var regionScaleY : Number = height / regionOriginalHeight * scaleY;
var localX : Number = -width / 2 * scaleX + regionOffsetX * regionScaleX;
var localY : Number = -height / 2 * scaleY + regionOffsetY * regionScaleY;
var localX : Number = -width * 0.5 * scaleX + regionOffsetX * regionScaleX;
var localY : Number = -height * 0.5 * scaleY + regionOffsetY * regionScaleY;
var localX2 : Number = localX + regionWidth * regionScaleX;
var localY2 : Number = localY + regionHeight * regionScaleY;

var radians : Number = rotation * Math.PI / 180;
var cos : Number = Math.cos(radians);
var sin : Number = Math.sin(radians);
var localXCos : Number = localX * cos + x;
var localXSin : Number = localX * sin;
var localYCos : Number = localY * cos + y;
var localYSin : Number = localY * sin;
var localX2Cos : Number = localX2 * cos + x;
var localX2Sin : Number = localX2 * sin;
var localY2Cos : Number = localY2 * cos + y;
var localY2Sin : Number = localY2 * sin;
offset[BLX] = localXCos - localYSin;
offset[BLY] = localYCos + localXSin;
offset[ULX] = localXCos - localY2Sin;
offset[ULY] = localY2Cos + localXSin;
offset[URX] = localX2Cos - localY2Sin;
offset[URY] = localY2Cos + localX2Sin;
offset[BRX] = localX2Cos - localYSin;
offset[BRY] = localYCos + localX2Sin;
var ulDist : Number = Math.sqrt(localX * localX + localY * localY);
var ulAngle : Number = Math.atan2(localY, localX);
var urDist : Number = Math.sqrt(localX2 * localX2 + localY * localY);
var urAngle : Number = Math.atan2(localY, localX2);
var blDist : Number = Math.sqrt(localX * localX + localY2 * localY2);
var blAngle : Number = Math.atan2(localY2, localX);
var brDist : Number = Math.sqrt(localX2 * localX2 + localY2 * localY2);
var brAngle : Number = Math.atan2(localY2, localX2);

offset[BLX] = Math.cos(radians - blAngle) * blDist + x;
offset[BLY] = Math.sin(radians - blAngle) * blDist + y;
offset[ULX] = Math.cos(radians - ulAngle) * ulDist + x;
offset[ULY] = Math.sin(radians - ulAngle) * ulDist + y;
offset[URX] = Math.cos(radians - urAngle) * urDist + x;
offset[URY] = Math.sin(radians - urAngle) * urDist + y;
offset[BRX] = Math.cos(radians - brAngle) * brDist + x;
offset[BRY] = Math.sin(radians - brAngle) * brDist + y;
}

public function setUVs(u : Number, v : Number, u2 : Number, v2 : Number, rotate : Boolean) : void {
Expand Down
Binary file modified spine-starling/spine-starling-example/lib/spine-as3.swc
Binary file not shown.
Binary file modified spine-starling/spine-starling/lib/spine-as3.swc
Binary file not shown.

0 comments on commit 262bc26

Please sign in to comment.