Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-31-2010, 04:41 AM   #15 (permalink)
iPhoneDevelopment
Banned
 
Join Date: Dec 2009
Posts: 61
Default

It worked!! (the only change I made was to remove '.frame' from 'lowerFrame' in the 'CGRectIntersectsRect' statement)

I have written this code to detect swipes and move the character left and right:

Code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
	
	character.animationImages = [NSArray arrayWithObjects:
								 [UIImage imageNamed:@"character.png"],
								 [UIImage imageNamed:@"character2.png"], nil];
	character.animationDuration = 0.5;
	character.animationRepeatCount = 1;
	[character startAnimating];
	[self.view addSubview:character];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
	
	UITouch *touch = [touches anyObject];
    startTouchPosition = [touch locationInView:self];
	
	UITouch *touch = [touches anyObject];
	CGPoint currentTouchPosition = [touch locationInView:self];
	
    if (fabsf(startTouchPosition.x - currentTouchPosition.x) >= HORIZ_SWIPE_DRAG_MAX &&
        fabsf(startTouchPosition.y - currentTouchPosition.y) <= VERT_SWIPE_DRAG_MIN)
    {
        if (startTouchPosition.y < currentTouchPosition.y)
            [self characterJump:touches withEvent:event]; }
	
	CGPoint location = [touch locationInView:touch.view];
	CGPoint xLocation = CGPointMake(location.x,character.center.y);
	character.center = xLocation;
}
Xcode returns a ton of errors when I try to compile it.. but I'm not sure why?? I also want my character to jump when a swipe is detected, but I don't want to just animate him because then he wont react to landing on a block (I want him to always be travelling down the screen, unless he is on a block or in a jump).

Sorry if this is a lot of questions :S

Cam

Last edited by iPhoneDevelopment; 01-31-2010 at 06:17 AM.
iPhoneDevelopment is offline   Reply With Quote
 

» Advertisements
» Online Users: 365
19 members and 346 guests
ADY, apatsufas, Dani77, Dattee, dcool, Desert Diva, HDshot, HemiMG, ilmman, jakerocheleau, leahov, mer10, michelle, nobre84, Robiwan, smithdale87, thh022, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,724
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.