C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 30th, 2012, 12:13 AM
DelightedD0D DelightedD0D is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 DelightedD0D User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 3 sec
Reputation Power: 0
Touches ended is causing issues with segue animation

Im making a fairly simple app for the iPad using xCode (written in objective c of course).

Im using the below code for touches ended. After a few uiimageviews are moved around a bit I call a segue in my code like this: [self performSegueWithIdentifier: @"segueToLevel2" sender: self]

The segue's transition types are set to "cross dissolve".

With the code below everything works fine until I get to level 5. On level five when the segue is called it does a corner to corner flip instead of the cross dissolve and from this point on every segue in my app does this flip instead of what they were set to do. If I take out my touches ended method everything works as expected so it seems the problem must be here. I just cant figure out why this works for levels 1-4 but craps out on level 5. Any help would be greatly appreciated....im loosing my mind here.


Code:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
switch (level) {
    case 1:{

        if ((piece11.hidden == YES) && (piece1moving.hidden == NO) && (piece1placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece1moving.frame = CGRectMake(-65, 153, 490, 422);
            [UIView commitAnimations];
            [NSTimer scheduledTimerWithTimeInterval:3 target:(self) selector:@selector(moveToFront) userInfo:(nil) repeats:NO];
            [NSTimer scheduledTimerWithTimeInterval:1 target:(self) selector:@selector(singlePieceCallback) userInfo:(nil) repeats:NO];   

        }    
    }
        break;
    case 2:{
        UITouch *touch1 = [[event allTouches] anyObject];
        if (([touch1 view] == piece1) && (piece1placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece1.frame = CGRectMake(47, 402, 305, 312);
            [UIView commitAnimations];

        }
        if (([touch1 view] == piece2) && (piece2placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece2.frame = CGRectMake(34, 4, 291, 399);
            [UIView commitAnimations];
        }
    }
        break;
    case 3:{
        UITouch *touch1 = [[event allTouches] anyObject];
        if (([touch1 view] == piece1) && (piece1placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece1.frame = CGRectMake(1, 419, 308, 356);
            [UIView commitAnimations];


        }
        if (([touch1 view] == piece2) && (piece2placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece2.frame = CGRectMake(-7, 67, 291, 315);
            [UIView commitAnimations];

        }
        if (([touch1 view] == piece3) && (piece3placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece3.frame = CGRectMake(-16, 169, 427, 310);
            [UIView commitAnimations];

        }
    }
        break;
    case 4:{
        UITouch *touch1 = [[event allTouches] anyObject];

        if (([touch1 view] == piece1) && (piece1placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece1.frame = CGRectMake(0, 76, 219, 261);
            [UIView commitAnimations];


        }
        if (([touch1 view] == piece2) && (piece2placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece2.frame = CGRectMake(89, 485, 255, 287);
            [UIView commitAnimations];

        }
        if (([touch1 view] == piece3) && (piece3placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece3.frame = CGRectMake(103, 197, 305, 330);
            [UIView commitAnimations];

        }
        if (([touch1 view] == piece4) && (piece4placedstate == 0)){
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece4.frame = CGRectMake(5, 277, 228, 294);

        }

    }
        break;
    case 5:{
        UITouch *touch1 = [[event allTouches] anyObject];
        if (([touch1 view] == piece1) && (piece1placedstate == 0)) {
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece1.frame = CGRectMake(115, 89, 247, 263);
            [UIView commitAnimations];


        }
        if (([touch1 view] == piece2) && (piece2placedstate == 0)) {
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece2.frame = CGRectMake(14, 497, 211, 271);
            [UIView commitAnimations];

        }
        if (([touch1 view] == piece3) && (piece3placedstate == 0)) {
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece3.frame = CGRectMake(92, 248, 244, 272);
            [UIView commitAnimations];

        }
        if (([touch1 view] == piece4) && (piece4placedstate == 0)) {
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece4.frame = CGRectMake(87, 458, 228, 294);

        }
        if (([touch1 view] == piece5) && (piece5placedstate == 0)) {
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1.0];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            piece5.frame = CGRectMake(-13, 102, 244, 303);

        }
    }
        break;


    default:
        break;
}

Reply With Quote
  #2  
Old October 2nd, 2012, 06:13 AM
DelightedD0D DelightedD0D is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 DelightedD0D User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 3 sec
Reputation Power: 0
I'm still not sure what was causing my issue with the above code but I have found a solution in re-writing my code and using a UIPanGestureRecognizer like the one below attached to each of the pieces. This works perfectly throughout.

Code:
- (void) dragGesture5:(UIPanGestureRecognizer *) panGesture {
CGPoint translation = [panGesture translationInView:self.view];

switch (panGesture.state) {
    case UIGestureRecognizerStateBegan:{

        originalCenter = piece5.center;
        [self.view bringSubviewToFront:piece5];


    }
        break;
    case UIGestureRecognizerStateChanged:{

        piece5.center = CGPointMake(piece5.center.x + translation.x,
                                     piece5.center.y + translation.y);
        [self checkColision];


    }
        break;
    case UIGestureRecognizerStateEnded:{            

        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:1.0];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        piece5.center = originalCenter;
        [UIView commitAnimations];




    }
        break;
    default:
        break;
}

[panGesture setTranslation:CGPointZero inView:self.view];
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Touches ended is causing issues with segue animation

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap