Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jeremy1026

macrumors 68020
Original poster
Nov 3, 2007
2,215
1,029
Sorry for the incredibly un-descriptive title, but I don't even know what's wrong.

I am trying to make it so that when a peg is selected it disappears, if there are 20 pegs on the board (pegsLeft.) Then if there aren't 20 pegs left on the board I want to application to show possible peg moves. I can get the peg to remove when selected with the board full, but that is it. Can someone diagnose whats wrong with my code...

Code:
-(IBAction)moveCrossPeg1 {
	if (pegsLeft == 20) {
		crossPeg1.hidden = YES;
		crossPeg1.enabled = NO;
		pegsLeft = pegsLeft - 1;
		pegsLeftLabel.text = [NSString stringWithFormat:@"Pegs Remaining: %i",pegsLeft];
	}
	if ((pegsLeft < 20) && (crossPeg7.enabled == NO) && (crossPeg3.enabled == YES)) {
		crossPeg7.enabled = YES;
		crossPeg7Choose = YES;
		UIImage *editPeg = [UIImage imageNamed:@"editpeg.png"];
		[crossPeg7 setImage:editPeg forState:UIControlStateNormal];
		[editPeg release];
	}
} 
	
-(IBAction)moveCrossPeg7 {
		if (pegsLeft == 20) {
			crossPeg7.hidden = YES;
			crossPeg7.enabled = NO;
			pegsLeft = pegsLeft - 1;
			pegsLeftLabel.text = [NSString stringWithFormat:@"Pegs Remaining: %i",pegsLeft];
		}
		if ((pegsLeft < 20) && (crossPeg1.enabled == NO) && (crossPeg3.enabled == YES)) {
			crossPeg1.enabled = YES;
			crossPeg1Choose = YES;
			UIImage *editPeg = [UIImage imageNamed:@"editpeg.png"];
			[crossPeg1 setImage:editPeg forState:UIControlStateNormal];
			[editPeg release];
			[self goToCross];
		}
}
 

tawpie

macrumors newbie
Jul 8, 2008
18
0
what's going on with crossPeg3? If it's not enabled, nothing will happen when you have fewer than 20 pegs.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.