OK guys, Been fiddling around with the iPhone SDK for a long time, and recently a few things clicked and I can now get things going, yay.
But I'm still having trouble with objects etc.
I've got a UFO in a UIImageView that moves around the screen while animating, seems to be doing what I tell it, the problem is to add another UFO doesn't seem to be all that easy, but I get the impression it should be, I'm guessing the way the routines are written needs to be more generic...
I've been looking around using google, but I'm not telling it to look for the right things, any tips?
I couldn't even think of a good, descriptive thread title
But I'm still having trouble with objects etc.
I've got a UFO in a UIImageView that moves around the screen while animating, seems to be doing what I tell it, the problem is to add another UFO doesn't seem to be all that easy, but I get the impression it should be, I'm guessing the way the routines are written needs to be more generic...
Code:
- (void)viewDidLoad {
ufoPos = CGPointMake(5.0,5.0);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(moveUfo) userInfo:nil repeats:YES];
[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(animateUfo) userInfo:nil repeats:YES];
}
- (void)moveUfo{
theUfo.center = CGPointMake(theUfo.center.x+ufoPos.x, theUfo.center.y+ufoPos.y);
if(theUfo.center.x > 296 || theUfo.center.x < 24){
ufoPos.x = -ufoPos.x;
}
if(theUfo.center.y > 468 || theUfo.center.y < 12){
ufoPos.y = -ufoPos.y;
}
}
- (void)animateUfo {
NSArray *ufoArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"ufo1.png"],
[UIImage imageNamed:@"ufo2.png"],
[UIImage imageNamed:@"ufo3.png"],nil];
[theUfo setAnimationImages:ufoArray];
[theUfo setAnimationRepeatCount:1];
[theUfo setAnimationDuration:0.5];
[self.view addSubview:theUfo];
[theUfo startAnimating];
[ufoArray release];
}
I've been looking around using google, but I'm not telling it to look for the right things, any tips?
I couldn't even think of a good, descriptive thread title