Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   Multiple Images Falling Issues on XCODE (http://www.mac-forums.com/forums/os-x-development-darwin/309321-multiple-images-falling-issues-xcode.html)

heman85 03-08-2014 10:24 PM

Multiple Images Falling Issues on XCODE
 
Please help... I have this code on 3 images (stars) goes down on my game. The difference between stars codes is the delay timing on perform.

[self performSelector:@selector(star1Animation) withObject:nil afterDelay:2.0];
star1 = 2.0 seconds, star2 = 4.0 seconds and star3 = 6.0 seconds

When I load the game the star 1 goes down fine, but should be fall again on the next 2 seconds, this never happen. 4 seconds later, falling the star2 and on 6 seconds later falling the star3. The problem is: Star 1 never go down again until all the stars goes down. Then, for some reason, All the stars fall at the same time like 15 seconds later. Please Help. What I miss? Thanks for your help.

Here the Code .m file

-(void)star1Animation
{
// drop1 Down Movement Speed
star1tm = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(star1Code) userInfo:nil repeats:YES];
star2tm = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(star1Code) userInfo:nil repeats:YES];
star3tm = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(star1Code) userInfo:nil repeats:YES];
}

-(void) star1Code
{
star1.center = CGPointMake(star1.center.x, star1.center.y +2);

if (star1.center.y > 590) {
ramdomPosition = arc4random() %265;
ramdomPosition = ramdomPosition +54;
star1.center = CGPointMake(ramdomPosition, -60);

// Time to Show drop1 Again in x Seconds
[[NSRunLoop currentRunLoop]runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];

}
}

-(void)star2Animation
{
// drop2 Down Movement Speed
star2tm = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(star2Code) userInfo:nil repeats:YES];
}

-(void) star2Code
{
star2.center = CGPointMake(star2.center.x, star2.center.y +2);

if (star2.center.y > 590) {
ramdomPosition = arc4random() %265;
ramdomPosition = ramdomPosition +54;

star2.center = CGPointMake(ramdomPosition, -60);

// Time to Show drop1 Again in x Seconds
[[NSRunLoop currentRunLoop]runUntilDate:[NSDate dateWithTimeIntervalSinceNow:4.0]];
}
}

-(void)star3Animation
{
// drop3 Down Movement Speed
star3tm = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(star3Code) userInfo:nil repeats:YES];
}

-(void) star3Code
{
star3.center = CGPointMake(star3.center.x, star3.center.y +2);

if (star3.center.y > 590) {
ramdomPosition = arc4random() %265;
ramdomPosition = ramdomPosition +54;
star3.center = CGPointMake(ramdomPosition, -60);

// Time to Show drop1 Again in x Seconds
[[NSRunLoop currentRunLoop]runUntilDate:[NSDate dateWithTimeIntervalSinceNow:6.0]];

}
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

[self performSelector:@selector(star1Animation) withObject:nil afterDelay:2.5];
[self performSelector:@selector(star2Animation) withObject:nil afterDelay:4.5];
[self performSelector:@selector(star3Animation) withObject:nil afterDelay:6.5];
}


All times are GMT -4. The time now is 11:04 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.