PDA

View Full Version : Help needed with code.




Jeremy1026
Aug 4, 2008, 01:53 PM
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...

-(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
Aug 5, 2008, 12:32 AM
what's going on with crossPeg3? If it's not enabled, nothing will happen when you have fewer than 20 pegs.

divinemercy
Aug 5, 2008, 12:41 AM
Am i really the only one who likes to put comprehensive commenting in my code?

lol....