Hey Everyone,
Just in need of abit of help if possible
Im trying to build a slider puzzle at the moment, id like to be able to count the number of moves that are made in the puzzle. Ive started out like this so far:
play.h set up an integer and label.
Code:
int moves;
CCLabel *moveLabel;
play.m created the label to show the amount of moves.
Code:
moveLabel = [[CCLabel labelWithString: [NSString stringWithFormat:@"Moves: %d", moves] dimensions: CGSizeMake(130, 27) alignment: UITextAlignmentRight fontName:@"Marker Felt" fontSize: 25.0] retain];
moveLabel.position = ccp(55,430);
[self schedule: @selector(tick3:) interval:1.0];
[self addChild: moveLabel];
The code that swaps the tiles is like so, i added the moves++; to the bottom of it:
Code:
-(void) changeWithTileA: (Tile *) a TileB: (Tile *) b sel : (SEL) sel{
CCAction *actionA = [CCSequence actions:[CCMoveTo actionWithDuration:kMoveTileTime position:[b pixPosition]], [CCCallFuncND actionWithTarget:self selector:sel data: a], nil];
CCAction *actionB = [CCSequence actions:[CCMoveTo actionWithDuration:kMoveTileTime position:[a pixPosition]], [CCCallFuncND actionWithTarget:self selector:sel data: b], nil];
[a.sprite runAction:actionA];
[b.sprite runAction:actionB];
[a trade:b];
moves++;
}
My thoughts were this would count every move that would be made, but im not sure how to reference this method in the label at the top specifically on this line:
Code:
[self schedule: @selector() interval:1.0];
tick3: isnt used anywhere, just wondered if any could help me out.
Cheers