pad rotated frames
This commit is contained in:
@@ -43,7 +43,7 @@ import jigsawx.math.Vec2;
|
|||||||
class HabitState extends FlxState {
|
class HabitState extends FlxState {
|
||||||
public function drawPieceShape( surface: FlxSprite, jig: JigsawPiece, scale:Float, c: FlxColor )
|
public function drawPieceShape( surface: FlxSprite, jig: JigsawPiece, scale:Float, c: FlxColor )
|
||||||
{
|
{
|
||||||
var points = [for (point in jig.getPoints()) new FlxPoint(point.x / scale, point.y / scale)];
|
var points = [for (point in jig.getPoints()) new FlxPoint(point.x / scale + ROT_PADDING, point.y / scale + ROT_PADDING)];
|
||||||
points.push(points[0]);
|
points.push(points[0]);
|
||||||
FlxSpriteUtil.drawPolygon(
|
FlxSpriteUtil.drawPolygon(
|
||||||
surface,
|
surface,
|
||||||
|
|||||||
@@ -302,10 +302,13 @@
|
|||||||
(pieceCamera.calculateScrollBounds rewardSprites uiCamera SCROLL_BOUND_MARGIN)
|
(pieceCamera.calculateScrollBounds rewardSprites uiCamera SCROLL_BOUND_MARGIN)
|
||||||
(save.flush)))
|
(save.flush)))
|
||||||
|
|
||||||
(source.makeGraphic (Std.int sourceRect.width) (Std.int sourceRect.height) FlxColor.TRANSPARENT true)
|
(var ROT_PADDING 2)
|
||||||
(source.pixels.copyPixels rewardSprite.pixels sourceRect (new Point 0 0))
|
(localVar fWidth (+ (Std.int sourceRect.width) (* 2 ROT_PADDING)))
|
||||||
|
(localVar fHeight (+ (Std.int sourceRect.height) (* 2 ROT_PADDING)))
|
||||||
|
(source.makeGraphic fWidth fHeight FlxColor.TRANSPARENT true)
|
||||||
|
(source.pixels.copyPixels rewardSprite.pixels sourceRect (new Point ROT_PADDING ROT_PADDING))
|
||||||
|
|
||||||
(mask.makeGraphic (Std.int sourceRect.width) (Std.int sourceRect.height) FlxColor.TRANSPARENT true)
|
(mask.makeGraphic fWidth fHeight FlxColor.TRANSPARENT true)
|
||||||
(drawPieceShape mask jig ros FlxColor.BLACK)
|
(drawPieceShape mask jig ros FlxColor.BLACK)
|
||||||
(FlxSpriteUtil.alphaMask s source.pixels mask.pixels)
|
(FlxSpriteUtil.alphaMask s source.pixels mask.pixels)
|
||||||
**(#when debug
|
**(#when debug
|
||||||
@@ -431,8 +434,8 @@
|
|||||||
minY (/ (apply min pointsY) ros)
|
minY (/ (apply min pointsY) ros)
|
||||||
maxX (/ (apply max pointsX) ros)
|
maxX (/ (apply max pointsX) ros)
|
||||||
maxY (/ (apply max pointsY) ros)
|
maxY (/ (apply max pointsY) ros)
|
||||||
rect (.fromTwoPoints (new FlxRect) (new FlxPoint minX minY) (new FlxPoint maxX maxY))
|
tlc (.add (new FlxPoint minX minY) ROT_PADDING ROT_PADDING)
|
||||||
originOffset (new FlxPoint (- s.origin.x minX) (- s.origin.y minY))
|
brc (.add (new FlxPoint maxX maxY) ROT_PADDING ROT_PADDING)
|
||||||
rotationPadding (dictGet rotationPaddingMap s)
|
rotationPadding (dictGet rotationPaddingMap s)
|
||||||
rect (.fromTwoPoints (new FlxRect) (tlc.addPoint rotationPadding) (brc.addPoint rotationPadding))
|
rect (.fromTwoPoints (new FlxRect) (tlc.addPoint rotationPadding) (brc.addPoint rotationPadding))
|
||||||
originOffset (new FlxPoint (- s.origin.x rect.x) (- s.origin.y rect.y))
|
originOffset (new FlxPoint (- s.origin.x rect.x) (- s.origin.y rect.y))
|
||||||
|
|||||||
Reference in New Issue
Block a user