Re: Hitting Layers
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