0

i have a question to handle a digitial joystick for iphone:

they joystick - innerThumb - moves to the position u touch on the display. But it should only start move, when u toch the thumbPic.

The Code:

- (void)makeHandle {
    self.handle = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];
    [self.handle setCenter:CGPointMake(self.bounds.size.width/2,
                                       self.bounds.size.height/2)];
    self.defaultPoint = self.handle.center;
    [self roundView:self.handle toDiameter:self.handle.bounds.size.width];
    [self addSubview:self.handle];

    self.thumbImageView = [[UIImageView alloc] initWithFrame:self.handle.frame];
    [self addSubview:self.thumbImageView];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [UIView animateWithDuration:.2 animations:^{
        self.alpha = 1;
    }];

        [self touchesMoved:touches withEvent:event];

}

So my idea is somthing like that - in tochesBegan i ask:

for (UITouch *touch in touches) {

   if (touch == self.handle.thumbImageView) {
        [self touchesMoved:touches withEvent:event];
    }
}

But UiTouch and UIImageView not equals types - i know that

someone an idea ?

greetz

Tobias
  • 95
  • 1
  • 9
  • I solved it: had the right idea – Tobias Jun 11 '14 at 18:29
  • for (UITouch *touch in touches) { CGPoint location = [touch locationInView:self]; if(CGPointEqualToPoint(location, self.thumbImageView.center)) { [self touchesMoved:touches withEvent:event]; } } – Tobias Jun 11 '14 at 18:30

0 Answers0