• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hitting Layers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hitting Layers


  • Subject: Re: Hitting Layers
  • From: Curious Yogurt <email@hidden>
  • Date: Mon, 4 Oct 2010 09:18:39 -0700

I solved the problem by examining checking to see if the game was in
fullscreen mode, and then changing how the NSPoint was calculated.  It turns
out that everything was slightly offset in fullscreen mode when using
convertScreetToBase:.  Not exactly a solution with an explanation; but at
least it is a solution (code below).

CGPoint point;

if ([[[[GameData sharedGameData] gameController] contentView]
isInFullScreenMode])

{

point = NSPointToCGPoint(mouseloc);

}

else {

NSPoint translated = [[gameController window] convertScreenToBase:mouseloc];

point = NSPointToCGPoint(translated);

}

CALayer *rootLayer = [[[gameController window] contentView] layer];

id hitLayer = [rootLayer hitTest:point];

if (![hitLayer isKindOfClass:[GameObjectLayer class]])

return nil;

else

return hitLayer;


On Sat, Oct 2, 2010 at 6:30 AM, Matt Neuburg <email@hidden> wrote:

> I'm wondering that too. CALayer's hitTest requires a point in *superlayer*
> coordinates. So I'm wondering if you're getting that wrong (as people often
> do, because it's so surprising), and maybe there's something about how
> you're obtaining mouseloc (your original point) that masks the issue when
> you're not in fullscreen mode. m.
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Hitting Layers (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: What does core data do during a Save As?
  • Next by Date: Re: What does core data do during a Save As?
  • Previous by thread: Re: Hitting Layers
  • Next by thread: Re: Flipped NSView + scaled NSAffineTransform = confusion
  • Index(es):
    • Date
    • Thread