Quote:
|
That should work. From there on you could create the method playCurrentLevel, remove the code within initWithGameSetup and add it in there. Call the playCurrentLevel method and see if it still works and move from there. Hope this helps.
|
You know - something strange is/was definitely going on. I've done the code you suggested, and have the same results I had before. So I moved my instantiation of the tmrCountDownStartLevel to the bottom of the initWithGameSetup. When I'm running through that, the program gets to the point in code within the initWithGameSetup:
Code:
//initialize variables
isAllowedToMove = NO;
isAllowedToShoot = NO;
//Setup countDownStartLevel timer
[self countDownLevel]; <-- Never gets called !!??!!
tmrCountDownStartLevel = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(countDownLevel) userInfo:nil repeats:YES];
and within self - the GameViewController - I have the countDownLevel implemented as:
Code:
-(void) countDownLevel {
//Show the countdown label for the current count that you are on: 3...2....1..
switch (countDownValue) {
case 3:
NSLog(@"3........");
break;
case 2:
NSLog(@"2........");
break;
case 1:
NSLog(@"1........");
break;
case 0:
NSLog(@"0........");
NSLog(@"Start Game!");
[tmrCountDownStartLevel invalidate];
tmrCountDownStartLevel = nil;
default:
break;
}
}
In the GameViewController.h I've already got the following:
Code:
//This is inside the @interface GameViewController : UIViewController {
NSTimer *tmrCountDownStartLevel;
// and then the property
@property(nonatomic, retain) NSTimer *tmrCountDownStartLevel;
// and the method declaration
-(void)countDownLevel;
So I compiled ok after that - and I had the exact same problem as when I tried to instantiate the timer from within the playCurrentLevel method I defined. After a little frustration, I realized that the "code-sense" colors that XCode provides for keywords, variables, etc. on the property declaration didn't match the color of the NSTimer variable declaration within the @interface. So I double checked the values and they appeared to be the exact same. So I copied/pasted the variable declaration for tmrCountDownStartLevel to the clipboard and used that to paste over the typing I did for tmrCountDownStartLevel on the @property portion. Then magically the color of the variables matched. And all of sudden I was falling into the countDownLevel method finally.
So obviously there must've just been a typo - but if you look at my code I originally posted, I don't see a typo - but by copy/paste the variable name instead of re-typing it, it worked! - I don't know if htat made sense or not, but Thank you for your help!
now it's onto creating a duckTimer to fire and make the duck start along a path - I would assume you need to get random values that are at least within the bounds of the game screen - and set the vDucks.center to that CGRectPoint(randomX,randomY) & all within an animation block so they appear to be flying, then if the player has not shot the duck when the vDucks.center reaches its destination, it will get another set of random X&Y to fly to -- provided the flightDestination count is less than some value I specify, and if it is the same - make the duck fly away off the screen - because the player can't shoot worth a darn.
Of course there is more to it, but it seems to make sense.
Thanks again for your work and assistance on this project.