New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Multiple Images Falling Issues on XCODE


Post Reply New Thread Subscribe

 
Thread Tools
heman85

 
Member Since: Mar 08, 2014
Posts: 1
heman85 is on a distinguished road

heman85 is offline
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]runUntilDateNSDate 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]runUntilDateNSDate 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]runUntilDateNSDate 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];
}
QUOTE Thanks

Post Reply New Thread Subscribe


« Accessing NSAlert Buttons | Flash player issue with Safari browser »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Airport Express performace issues with multiple devices connected walleyrund Internet, Networking, and Wireless 1 04-02-2009 10:16 AM
Microsoft Messenger 6.0.3 Issues - Cant send multiple messages Positive19 OS X - Apps and Games 3 04-02-2009 12:31 AM
Multiple Issues with my Brand new MBP userofreality Apple Notebooks 10 11-10-2006 09:04 AM
Having Some Issues with Disk Images. Need some Help. TTheInfamous1 OS X - Apps and Games 7 08-19-2005 04:03 PM
Xcode Issues with C/C++ Compilation jebradfo OS X - Development and Darwin 2 12-19-2003 03:29 PM

All times are GMT -4. The time now is 12:22 AM.

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

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?