Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6989307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:11:41+00:00 2026-05-27T19:11:41+00:00

-(id) init { // always call super init // Apple recommends to re-assign self

  • 0
-(id) init
{
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super" return value
    if( (self=[super initWithColor:ccc4(255,255,255,255)] )) {
        [UIApplication sharedApplication].idleTimerDisabled = YES;
        imageArray = [[NSMutableArray alloc]init];
        winSize = [[CCDirector sharedDirector]winSize];
        [self addEverything];
        [self schedule:@selector(imageBlink) interval:5.0f];
    }
    return self;
}

-(void)imageBlink{
    int tagNum = (arc4random() %9 )+1 ;

    for (CCSprite *object  in imageArray) {

        if (object.tag == tagNum) {

            [object runAction: [CCSequence actions:[CCBlink actionWithDuration:2 blinks:1],[CCFadeOut actionWithDuration:2], nil]];
            [[SimpleAudioEngine sharedEngine]playEffect:@"slap.mp3"];

            NSLog(@"blink");
            return;
        }
    }
}

-(void)addImage{
    self.imageTag = 1;
    for (int i = 0; i <3; i++) {
        for (int j =0; j<3; j++) {
            image = [CCSprite spriteWithSpriteFrameName:@"0002.png"];

            NSLog(@"%d",imageTag);
            [image setTag:self.imageTag];
            self.imageTag ++ ;
            image.position = ccp(STAGE_WIDTH/(3)*(j)+35+41, STAGE_HEIGHT/(3)*(i)+115+41);
            [imageArray addObject:image];
            [image setVisible:NO];
            [self addChild:image z:2];

        } 
    }
}

I scheduled a method named imaged blink to be call every 5 seconds. The method would make my sprite from an array to blink(appear and disappear). But after several calls(about 10 or more), the sprite stops blinking. However, the output through NSLog “blink” still appears in 5s intervals. I have this problem on both the iphone emulator and my ipod. Thanks for help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:11:41+00:00Added an answer on May 27, 2026 at 7:11 pm

    If an object is already running the blink sequence, and you run another, this may interfere with what’s happening on screen. I suggest to add the stopAllActions before running a new sequence.

    The other thing I noticed is that you run a CCFadeOut action. Keep in mind that after this action is done, the sprite’s opacity will be 0 and CCBlink changes the visible property but does not affect opacity. That means you should ensure that the sprite is at maximum opacity before starting the sequence:

    [object stopAllActions];
    object.opacity = 255;
    [object runAction: [CCSequence actions:[CCBlink actionWithDuration:2 blinks:1],[CCFadeOut actionWithDuration:2], nil]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Cocoa framework has a convention to always call self = [super init] in
Should I always release self when there is a failure inside init, or should
- init { if(![super init]) return nil; //the database is stored in the application
Possible Duplicate: Why doesn't the CLR always call value type constructors Found next code
class A(object): def __init__(self, a, b, c): #super(A, self).__init__() super(self.__class__, self).__init__() class B(A): def
I'd like to use a Mixin to always add some init functionality to my
For some or other reason when I call the init method and try and
I have the following code: class A(object): def __init__(self): self.name = A super(A, self).__init__()
I have a class: class A(object): def __init__(self,a,b,c,d,e,f,g,...........,x,y,z) #do some init stuff And I
I just noticed that if you try to call a non-existing init method on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.