Adam Tindale
Adam Tindale

Reputation: 1249

Get all touches on screen

I'm having a small issue. I'd like to receive all touches on the screen and for each one spawn a new video. The problem is that once a video is placed then it intercepts the touch points. I tried various values to go in locationInView but without any luck so far. Am I looking in the right place?

 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    CGPoint pointOnScreen = [[touches anyObject] locationInView:self.view];

    C4Movie *player = [C4Movie movieNamed:@"inception.mov"];
    player.shouldAutoplay = YES;
    player.loops = YES;
    player.center = pointOnScreen;
    [self.canvas addMovie:player];

 }
 @end

Upvotes: 2

Views: 246

Answers (2)

C4 - Travis
C4 - Travis

Reputation: 4492

Yes, you're looking in the right place, and Chris has it right about user interaction. You should try:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint pointOnScreen = [[touches anyObject] locationInView:self.view];
    C4Movie *player = [C4Movie movieNamed:@"inception.mov"];
    player.shouldAutoplay = YES;
    player.loops = YES;
    player.center = pointOnScreen;
    player.userInteractionEnabled = NO;
    [self.canvas addMovie:player];
}

However you're going to run into an issue with adding videos. Unfortunately, iOS / hardware only lets you have 4 video pipelines running at one time so you'll hit that pretty quickly.

If you want to add things to the screen as you touch and drag your finger, then you could also do the above code inside of the following method:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    //work your magic here
}

Upvotes: 3

Chris McGrath
Chris McGrath

Reputation: 1936

Try setting the userInteractionEnabled property of each video screen (assuming it is held in some sort of UIView) to NO - that way, touch events will pass through it and continue to be received by your handler.

Upvotes: 3

Related Questions