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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-04-2010, 05:23 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default Logical error help!!! please!!!

ok so i am having a logical error, and i don't know why. here is my trouble code:

Code:
- (void) expPlus{
	
	Doodle_Dodge1ViewController *doodle = [[Doodle_Dodge1ViewController alloc]init];
	
	if ([doodle wallCollision] == TRUE || [doodle ceilingCollision] == TRUE ) {
		exp ++;
		NSLog(@"exp is %i", exp);
		currentXp.text = [NSString stringWithFormat:@"%i",exp];
		[self rankSystem];
	}
}
and:

Code:
- (BOOL)wallCollision{
	
	if (two.center.x > 320 || two.center.x < 0 ) {
		pos.x = -pos.x;
		
		score ++;
		NSLog(@"score is %i", score);
		scorelabel.text = [NSString stringWithFormat:@"%i",score];
		hit = TRUE;
	}else {
		hit = FALSE;
	}
	return hit;
}

- (BOOL)ceilingCollision{

	if (two.center.y > 460 || two.center.y < 0 ) {
		pos.y = -pos.y;
		
		score ++;
		NSLog(@"score is %i", score);
		scorelabel.text = [NSString stringWithFormat:@"%i",score];
		hit = TRUE;
	}else {
		hit = FALSE;
	}
	return hit;

}
now as you can see, the ceilling and wall collision are called quite a bit. so once the hit equals true you would think the expPlus method would work, right? but it doesnt. please help with this logical error, my ranking system does not work without your help, and i will greatly appreciate it!
sumosumo84 is offline   Reply With Quote
Old 10-04-2010, 06:09 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

anyone?
sumosumo84 is offline   Reply With Quote
Old 10-04-2010, 07:11 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

anyone brave enough to answer? :P
sumosumo84 is offline   Reply With Quote
Old 10-04-2010, 07:30 PM   #4 (permalink)
iPhone SDK learner
 
Join Date: Feb 2010
Location: Illinois, USA
Posts: 421
Batman is on a distinguished road
Default

Can you post the -init method of Doodle_Dodge1ViewController?
__________________
Fast Flash Cards
Available on the App Store
Fast Flash Cards
Batman is offline   Reply With Quote
Old 10-04-2010, 08:10 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 105
daveMac is on a distinguished road
Default

Quote:
Originally Posted by sumosumo84 View Post
ok so i am having a logical error, and i don't know why. here is my trouble code:

Code:
- (void) expPlus{
	
	Doodle_Dodge1ViewController *doodle = [[Doodle_Dodge1ViewController alloc]init];
	
	if ([doodle wallCollision] == TRUE || [doodle ceilingCollision] == TRUE ) {
		exp ++;
		NSLog(@"exp is %i", exp);
		currentXp.text = [NSString stringWithFormat:@"%i",exp];
		[self rankSystem];
	}
}
and:

Code:
- (BOOL)wallCollision{
	
	if (two.center.x > 320 || two.center.x < 0 ) {
		pos.x = -pos.x;
		
		score ++;
		NSLog(@"score is %i", score);
		scorelabel.text = [NSString stringWithFormat:@"%i",score];
		hit = TRUE;
	}else {
		hit = FALSE;
	}
	return hit;
}

- (BOOL)ceilingCollision{

	if (two.center.y > 460 || two.center.y < 0 ) {
		pos.y = -pos.y;
		
		score ++;
		NSLog(@"score is %i", score);
		scorelabel.text = [NSString stringWithFormat:@"%i",score];
		hit = TRUE;
	}else {
		hit = FALSE;
	}
	return hit;

}
now as you can see, the ceilling and wall collision are called quite a bit. so once the hit equals true you would think the expPlus method would work, right? but it doesnt. please help with this logical error, my ranking system does not work without your help, and i will greatly appreciate it!
I'll gladly give you a hand, but I need more code than this. You can PM me if you like but if not, at least post what "hit" and "exp" are so I can understand a little better where the problem might me.
daveMac is offline   Reply With Quote
Old 10-04-2010, 10:06 PM   #6 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

How have you verified that hit is sometimes getting set?
RLScott is offline   Reply With Quote
Old 10-05-2010, 09:34 PM   #7 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

nevermind. i fixed it on my own. thanks for input guys
sumosumo84 is offline   Reply With Quote
Old 10-05-2010, 09:35 PM   #8 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

Quote:
Originally Posted by sumosumo84 View Post
nevermind. i fixed it on my own. thanks for input guys
what i did is move all the exp code into the main viewController.
sumosumo84 is offline   Reply With Quote
Reply

Bookmarks

Tags
engine, error, logical error, no error, variables

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 350
7 members and 343 guests
headkaze, mistergreen2011, nobstudio, Objective Zero, rayjeong, revg, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:11 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0