0

So I know you can have a transparent background with Sprite Kit by setting AllowsTransparency to true on the View and setting a clear background on the Scene:

var view = new SKView()
{
    ShowsFPS = true,
    ShowsNodeCount = true,
    ShowsDrawCount = true,
    Frame = View.Frame,
    AllowsTransparency = true
};

var scene = new SKScene(View.Bounds.Size)
{
    BackgroundColor = NSColor.Clear
};

Now if I draw an image on the scene is it possible to make only that image clickable and the background click through? (Essentially a custom shaped Sprite Kit View)

UPDATE: The image in the scene is a sprite that is animating with textures so the size of the SKView would have to change per frame I suppose.

Als the SKView is in a Window that has a NSWindowsStyle of Borderless and a background color of clear (So basically you can't see the window or click on it, however you can click on the ui elements on the window). So really all you see is the Sprite animating but because the SKView is rectangular you cant click through the transparent areas around the sprite.

Bob
  • 821
  • 1
  • 17
  • 36
  • `is it possible to make only that image clickable?` yes, but is it a static image? or is it animated? (i.e. why are you using SKView?) . After that, if a touch is calc'd to be within the transparent area of the image (UIImage?), we would pass the touch to the parent view... So need to know that info to answer your Q. FYI: Views are always rectangular, but you are apply transforms to them (CGAffineTransform) ;-) – SushiHangover Apr 09 '16 at 11:54
  • @SushiHangover I have updated the question so it is more clear. – Bob Apr 09 '16 at 16:45
  • SKView's are UIView subclasses, so you should be able to use the usual methods. You can probably subclass SKView and override the pointInside method to only return true if the point is within the display, which you can check with nodeAtPoint. Note that if you do this, you won't have to constantly change the size of the SKView, either; you can just display the sprites within the extents of the view, and let pointInside manage the tappable area of the view. – cc. Jul 28 '18 at 02:33

0 Answers0