Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Multiple Images Falling Issues on XCODE
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="heman85" data-source="post: 1571396" data-attributes="member: 322247"><p>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.</p><p></p><p>[self performSelector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star1Animation) withObject:nil afterDelay:2.0];</p><p>star1 = 2.0 seconds, star2 = 4.0 seconds and star3 = 6.0 seconds</p><p></p><p>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.</p><p></p><p>Here the Code .m file</p><p></p><p>-(void)star1Animation</p><p>{</p><p> // drop1 Down Movement Speed</p><p> star1tm = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star1Code) userInfo:nil repeats:YES];</p><p> star2tm = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star1Code) userInfo:nil repeats:YES];</p><p> star3tm = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star1Code) userInfo:nil repeats:YES];</p><p>}</p><p></p><p>-(void) star1Code</p><p>{</p><p> star1.center = CGPointMake(star1.center.x, star1.center.y +2);</p><p></p><p> if (star1.center.y > 590) {</p><p> ramdomPosition = arc4random() %265;</p><p> ramdomPosition = ramdomPosition +54; </p><p> star1.center = CGPointMake(ramdomPosition, -60);</p><p></p><p> // Time to Show drop1 Again in x Seconds</p><p> [[NSRunLoop currentRunLoop]runUntilDate<img src="/mac_images/images/smilies/Embarrassed.png" class="smilie" loading="lazy" alt=":[" title="Embarrassed :[" data-shortname=":[" />NSDate dateWithTimeIntervalSinceNow:2.0]];</p><p></p><p> }</p><p>}</p><p></p><p>-(void)star2Animation</p><p>{</p><p> // drop2 Down Movement Speed</p><p> star2tm = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star2Code) userInfo:nil repeats:YES];</p><p>}</p><p></p><p>-(void) star2Code</p><p>{</p><p> star2.center = CGPointMake(star2.center.x, star2.center.y +2);</p><p></p><p> if (star2.center.y > 590) {</p><p> ramdomPosition = arc4random() %265;</p><p> ramdomPosition = ramdomPosition +54;</p><p></p><p> star2.center = CGPointMake(ramdomPosition, -60);</p><p></p><p> // Time to Show drop1 Again in x Seconds</p><p> [[NSRunLoop currentRunLoop]runUntilDate<img src="/mac_images/images/smilies/Embarrassed.png" class="smilie" loading="lazy" alt=":[" title="Embarrassed :[" data-shortname=":[" />NSDate dateWithTimeIntervalSinceNow:4.0]];</p><p> }</p><p>}</p><p></p><p>-(void)star3Animation</p><p>{ </p><p> // drop3 Down Movement Speed</p><p> star3tm = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star3Code) userInfo:nil repeats:YES];</p><p>}</p><p></p><p>-(void) star3Code</p><p>{ </p><p> star3.center = CGPointMake(star3.center.x, star3.center.y +2);</p><p></p><p> if (star3.center.y > 590) {</p><p> ramdomPosition = arc4random() %265;</p><p> ramdomPosition = ramdomPosition +54;</p><p> star3.center = CGPointMake(ramdomPosition, -60);</p><p></p><p> // Time to Show drop1 Again in x Seconds</p><p> [[NSRunLoop currentRunLoop]runUntilDate<img src="/mac_images/images/smilies/Embarrassed.png" class="smilie" loading="lazy" alt=":[" title="Embarrassed :[" data-shortname=":[" />NSDate dateWithTimeIntervalSinceNow:6.0]];</p><p></p><p> }</p><p>}</p><p></p><p>- (void)viewDidLoad</p><p>{</p><p> [super viewDidLoad];</p><p> // Do any additional setup after loading the view, typically from a nib. </p><p></p><p> [self performSelector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star1Animation) withObject:nil afterDelay:2.5];</p><p> [self performSelector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star2Animation) withObject:nil afterDelay:4.5];</p><p> [self performSelector<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad :mad:" loading="lazy" data-shortname=":mad:" />selector(star3Animation) withObject:nil afterDelay:6.5];</p><p>}</p></blockquote><p></p>
[QUOTE="heman85, post: 1571396, member: 322247"] 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]; } [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Multiple Images Falling Issues on XCODE
Top