Reputation: 483
I am trying to make Pong for Mac. For the ball bounce code, I am trying to access the ball's center. The ball is a NSImageView. For iOS programming, I can just access a UIImageView's center by calling
ball.center = ...;
How can I do this with an NSImageView. Sorry if this is dumb, I'm new to Cocoa programming.
Upvotes: 0
Views: 838
Reputation: 38728
You could add a simple category like:
- (void)ps_setCenter:(NSPoint)center;
{
[self setFrameOrigin:NSMakePoint(center.x - (self.frame.size.width * 0.5f),
center.y - (self.frame.size.height * 0.5f))];
[self setNeedsDisplay:YES];
}
Upvotes: 3