i have a problem figuring out exactly whats wrong here:
-(void) fireShots {
[laserBeam stop];
[laserBeam setCurrentTime:0];
[laserBeam play];
UIImageView *aShot = [[UIImageView alloc] initWithFrame:CGRectMake(actorImage.center.x, actorImage.center.y, 26, 36)];
[aShot setImage:[UIImage imageNamed:@"Laser- rød.png"]];
[allShots addObject:aShot];
if (moveAllShots == nil)
moveAllShots = [NSTimer scheduledTimerWithTimeInterval:1.0/50
target:self
selector:@selector(moveAllShots)
userInfo:nil
repeats:YES];
[actorImage.superview addSubview:aShot];
}
The method have 3 errors: Expected ; after expression (tries to fix it by inserting it at the moveallShots == nil, which is obviously incorrect.
Expected Expression (same line, it is the line that says [allShots addObject:aShot];
use of undeclared identifier aShot, that can’t be true either as it is made in that method.
Really can’t figure this one out. Thanks on advance,
/JBJ
From your sample method
fireShotsit looks like you have never definedlaserBeam,allShots, andmoveAllShots. Your errors will be solved by defining the variables in the local scope. Looking at how you are trying to use the variables you may be better off defining a custom class and adding the variables as properties using accessors to get and set the values.For example: since
allShotsis defined in your header file, use a property to access that instance variable.For use on using properties, see: The Objective-C Programming Language: Declared Properties
A google search will also turn up with some concise tutorials.