fix match zones for baked pieces
This commit is contained in:
@@ -155,6 +155,7 @@
|
||||
(prop &mut :Map<Int,JigsawPiece> pieceData (new Map))
|
||||
(prop &mut :Map<Int,Array<KissExtendedSprite>> connectedPieces (new Map))
|
||||
(prop &mut :Map<KissExtendedSprite,Int> indexMap (new Map))
|
||||
(prop &mut :Map<KissExtendedSprite,FlxPoint> rotationPaddingMap (new Map))
|
||||
(prop &mut :Map<Int,KissExtendedSprite> spriteMap (new Map)) // Because rewardSprites will be re-ordered in depth handling, this is required
|
||||
|
||||
(prop &mut lastRewardFileIndex -1)
|
||||
@@ -309,7 +310,13 @@
|
||||
(FlxSpriteUtil.alphaMask s source.pixels mask.pixels)
|
||||
**(#when debug
|
||||
(kiss_flixel.SpriteTools.writeOnSprite "$i" 32 s (object x (Percent 0.5) y (Percent 0.5)) FlxColor.RED))
|
||||
(s.loadRotatedGraphic s.pixels 4)
|
||||
(let [ow s.frameWidth
|
||||
oh s.frameHeight]
|
||||
(s.loadRotatedGraphic s.pixels 4 -1 /*false true*/)
|
||||
(let [nw s.frameWidth
|
||||
nh s.frameHeight]
|
||||
(dictSet rotationPaddingMap s (.scale (new FlxPoint (- nw ow) (- nh oh)) 0.5))))
|
||||
|
||||
|
||||
(set s.cameras [pieceCamera])
|
||||
|
||||
@@ -426,6 +433,9 @@
|
||||
maxY (/ (apply max pointsY) ros)
|
||||
rect (.fromTwoPoints (new FlxRect) (new FlxPoint minX minY) (new FlxPoint maxX maxY))
|
||||
originOffset (new FlxPoint (- s.origin.x minX) (- s.origin.y minY))
|
||||
rotationPadding (dictGet rotationPaddingMap s)
|
||||
rect (.fromTwoPoints (new FlxRect) (tlc.addPoint rotationPadding) (brc.addPoint rotationPadding))
|
||||
originOffset (new FlxPoint (- s.origin.x rect.x) (- s.origin.y rect.y))
|
||||
rotated (rect.getRotatedBounds s.angle originOffset)]
|
||||
(+= rotated.x s.x)
|
||||
(+= rotated.y s.y)
|
||||
|
@@ -61,7 +61,7 @@ class KissExtendedSprite extends flixel.addons.display.FlxExtendedSprite {
|
||||
|
||||
override function update(elapsed:Float) {
|
||||
#if debug
|
||||
color = (mouseOver && pixelPerfect(_dragPixelPerfectAlpha)) ? FlxColor.LIME : FlxColor.WHITE;
|
||||
// color = (mouseOver && pixelPerfect(_dragPixelPerfectAlpha)) ? FlxColor.LIME : FlxColor.WHITE;
|
||||
#end
|
||||
super.update(elapsed);
|
||||
}
|
||||
@@ -88,9 +88,29 @@ class KissExtendedSprite extends flixel.addons.display.FlxExtendedSprite {
|
||||
}
|
||||
|
||||
function pixelPerfect(alpha) {
|
||||
return FlxCollision.pixelPerfectPointCheck(Math.floor(FlxG.mouse.x), Math.floor(FlxG.mouse.y), this, alpha);
|
||||
return pixelPerfectPointCheck(Math.floor(FlxG.mouse.x), Math.floor(FlxG.mouse.y), this, alpha);
|
||||
}
|
||||
|
||||
static function pixelPerfectPointCheck(PointX:Int, PointY:Int, Target:FlxSprite, AlphaTolerance:Int = 1):Bool
|
||||
{
|
||||
if (FlxG.renderTile)
|
||||
{
|
||||
Target.drawFrame();
|
||||
}
|
||||
|
||||
// How deep is pointX/Y within the rect?
|
||||
var test:BitmapData = Target.framePixels;
|
||||
|
||||
var pixelAlpha = FlxColor.fromInt(test.getPixel32(Math.floor(PointX - Target.x), Math.floor(PointY - Target.y))).alpha;
|
||||
|
||||
if (FlxG.renderTile)
|
||||
{
|
||||
pixelAlpha = Std.int(pixelAlpha * Target.alpha);
|
||||
}
|
||||
|
||||
// How deep is pointX/Y within the rect?
|
||||
return pixelAlpha >= AlphaTolerance;
|
||||
}
|
||||
|
||||
override function checkForClick():Void
|
||||
{
|
||||
|
Reference in New Issue
Block a user