IPhone sdk, more accurate collision detection and set the frame/bounds of UIImageView...
- by Harry
Hey, Im having a big problem with my app at the moment, its all too inaccurate.
I have a image of a ballooon, https://dl.dropbox.com/u/2578642/Balloonedit.png
And i have a dart which if it collides into the balloon the game ends.
At the moment i am populating the image of the balloon with 8 UIImageViews. and i am detecting if the dart hits them, this was suppose to make it really accurate but its not, the dart pretty much passes through the balloon when its meant to collide, so i have a plan, is there any way to detect when the dart hits the actual image of the balloon not the UIImageView, or is there any way to draw a border around the balloon and detect if it hits that?
currently i am using this code to detect the collision:
if (CGRectIntersectsRect(pinend.frame, balloonbit1.frame)){
[maintimer invalidate];
accelManeger.delegate = nil;
[ball setImage:img];
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:0.3];
ball.transform = CGAffineTransformMakeScale(2, 2);
[UIImageView commitAnimations];
}
So in one method there are 40 of these bits of code and as you can imagine it is not very accurate/fast to respond. So like i said is there a way to draw a border or something around the balloon and detect the collision between the border and dart? Because then i would imagine it would run a lot smother because it would only have to process 5 bits of code.
Thanks for any help.
This is a big Question so if you can answer it i will buy your app :)
Cheers,
Harry :/