I have the following code:
CCProgressTimer *aTimer;
-(void) generateDungeon {
srand (time(NULL));
[self initDungeonArray];
int numRooms = RNDM(10,100);
for (int a=0; a< numRooms; a++) {
[self makeRandomRoom];
aTimer.percentage += 100/numRooms;
}
[self connectTheRooms];
[self placeStairs];
}
The problem is that during the loop the timer does not get updated on screen, then suddenly (after the loop finishes I think) fills up to nearly full. I don’t understand why this is happening. I thought that when you change the percentage, the image would update.
Can anyone help me understand what I should be understanding?
Thanks.
Your image(in this case, you progress timer), updates on the screen in draw() and visit() methods. They are called every tick. Here you change it’s value in one tick. So during previous drawing the timer value was 0 percent, and on the next drawing it’s value will be 100
you make it in the single thread. so your timer will not be update in this case. to create updatable timer, you can try to move your long working code to the separate thread. then you will be able to update timer.