Skip to content

FlxMouseEvent: pixelPerfect checks no longer honor clipRects #3568

@Geokureli

Description

@Geokureli

Likely caused by #3419

Noticed in FlxLightPuzzle on dev, but not master. sprite.getPixelAt needs to check clipRect specifically:

	/**
	 * Determines which of this sprite's pixels are at the specified world coordinate, if any.
	 * Factors in `scale`, `angle`, `offset`, `origin`, `scrollFactor`, `clipRect`, `flipX` and `flipY`.
	 * 
	 * @param  worldPoint  The point in world space
	 * @param  camera      The camera, used for `scrollFactor`. If `null`, `getDefaultCamera()` is used.
	 * @return a `FlxColor`, if the point is in the sprite's graphic, otherwise `null` is returned.
	 * @since 5.0.0
	 */
	public function getPixelAt(worldPoint:FlxPoint, ?camera:FlxCamera):Null<FlxColor>
	{
		final point = worldToFramePosition(worldPoint, camera, FlxPoint.weak());
		
		final overlaps = point.x >= 0 && point.x <= frameWidth && point.y >= 0 && point.y <= frameHeight
			&& (clipRect == null || clipRect.containsPoint(point));
		
		if (!overlaps)
		{
			point.put();
			return null;
		}
		
		return transformColor(frame.getPixelAt(point));
	}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions