Hi everyone. well I have an image of a drip of water and an image of a plughole. The image of the drip moves freely with the accelerometer and the plug is a static image.
I can move the drip near the plug but it disappears as soon as the bounding box touches the plug bounding box. I want the two centres to be over each other before it disappears.... so it looks like the drip disappears into the plughole rather than just before it touches it.
here is a snippet from .m file...
any help would be super fantastic!!
thanks
x.x.
I can move the drip near the plug but it disappears as soon as the bounding box touches the plug bounding box. I want the two centres to be over each other before it disappears.... so it looks like the drip disappears into the plughole rather than just before it touches it.
here is a snippet from .m file...
Code:
-(void)awakeFromNib {
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:1.0/30.0];
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
valueX = acceleration.x*30.0;
valueY = acceleration.y*30.0;
int newX = (int)(ball.center.x +valueX);
if (newX > 320-BALL_RADIUS)
newX = 320-BALL_RADIUS;
if (newX < 0+BALL_RADIUS)
newX = 0+BALL_RADIUS;
int newY = (int)(ball.center.y -valueY);
if (newY > 460-BALL_RADIUS)
newY = 460-BALL_RADIUS;
if (newY < 0+BALL_RADIUS)
newY = 0+BALL_RADIUS;
CGPoint newCenter = CGPointMake(newX, newY);
ball.center = newCenter;
[self checkCollision];
}
-(void)checkCollision{
if(CGRectIntersectsRect(drip.frame, plug.frame)) {
[ball removeFromSuperview];
}
}
any help would be super fantastic!!
thanks
x.x.