Page 1 of 1

[space addBounds:self.view.bounds ....]

PostPosted: Mon Feb 20, 2012 1:40 am
by whatever
Hi I'm quite new to chipmunk. I started to follow the Simple Objective-Chipmunk Tutorial this morning. When I changed the button from a UIButton to a UIImageView, the bounds became weird. It was shifted left and down. Moreover, the shift amounts are different according to different image size.
Here's the only part that I changed:
Code: Select all
button = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pig.png"]];
button.backgroundColor = [UIColor blackColor];
button.bounds = CGRectMake(0, 0, SIZE, SIZE);
button.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonClicked)];
[button addGestureRecognizer:tap];

When I tried to change the corner radians of the button, same thing happened again.
Any ideas?

Re: [space addBounds:self.view.bounds ....]

PostPosted: Mon Feb 20, 2012 12:52 pm
by slembcke
Confusingly, different UIView objects (buttons, image views, etc) don't all have their centers and transforms set up the same. You might find this helpful: