Re: A couple questions relevant to games
Re: A couple questions relevant to games
- Subject: Re: A couple questions relevant to games
- From: Jens Alfke <email@hidden>
- Date: Sun, 17 Feb 2008 20:48:52 -0800
On 17 Feb '08, at 7:20 PM, Aaron MacDonald wrote:
This works when the window is first shown, but it doesn't handle
resizing well. When I have it set to not expand and I shrink the
window to smaller than the tile view's initial size, its tiles get
squished out of proportion (so far I'm trying to get square tiles).
Here's some old code of mine that ensures its window's main view
remains square, by always preserving the difference between the
window's height and width. This goes in the window's delegate object:
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
{
// This will get called _before_ awakeFromNib if frame default
has been set!
if( _extraHeight == 0.0 ) {
NSRect frame = [_window frame];
_extraHeight = frame.size.height - frame.size.width;
} else {
frameSize.height = frameSize.width + _extraHeight;
}
return frameSize;
}
There's also the issue of the grid dimensions been magic numbers. I
want an initialization method where I provide the grid width, grid
height, and tile size. It's just that I can't see where I'd be able
to call that since it appears I can only access my tile view through
Interface Builder. This is especially troublesome if I want to have
more than one tile view, such where I have a main view screen and a
mini-map.
Yeah, you can't use initialization methods with objects in nibs. You
can implement -awakeFromNib on the view subclass, or on an app/window
controller that will then tell the view to set itself up.
—Jens_______________________________________________
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