I am developing my first game for iPhone and having this issue. The coordinate system seems to be way off, most likely I am doing something wrong.
I have a UIViewController, and it’s set as a RootViewController. The viewController calls a UIView after that;
App delegate;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MyViewController *myViewController = [[MyViewController alloc] init];
[[self window] setRootViewController:myViewController];
ViewController;
CGRect frame = [[UIScreen mainScreen] bounds];
MyView *v = [[MyView alloc] initWithFrame:frame];
[self setView:v];
View;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
.
.
.
[myCALayer setBounds:CGRectMake(0.0, 0.0, width, height)];
[myCALayer setPosition:CGPointMake(x, y)];
So the 0.0 is suppose to be top left corner, but on my dev environment, it’s out side of the visible screen, still somewhere top left but when I draw an image at 0.0, I can only see the small portion of right bottom of it.
Any idea why this happens?
position
Specifies the receiver’s position in the superlayer’s coordinate system. Animatable.
Discussion
The position is relative to anchorPoint. The value of this property is specified in points. The default is (0.0, 0.0).
See “Layer Geometry and Transforms” in Core Animation Programming Guide for more information on the relationship between the bounds, anchorPoint and position properties.
In default anchorPoint is set up to (0.5,0.5) it’s center of your layer, so if you set the position to (0,0) center of your layer will be at (0,0) – only bottom right corner will be visible, you need to set anchorPoint to (0,0) then set position to (0,0).