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 6677437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:07:11+00:00 2026-05-26T04:07:11+00:00

I am new to Cocos2D. I am making a simple game for iPhone in

  • 0

I am new to Cocos2D. I am making a simple game for iPhone in which I want my sprite to disappear with some animation. Till now I can make it disappear with the following code:-

-(void)selectSpriteForTouch:(CGPoint)touchLocation
{ 

    for (CCSprite *sprite in targets)  
    {

        if (CGRectContainsPoint(sprite.boundingBox, touchLocation)) 
        {
            NSLog(@"sprite was touched");

            [sprite.parent removeChild:sprite cleanup:YES];
            [[SimpleAudioEngine sharedEngine] playEffect:@"pop.wav"];
            [[SimpleAudioEngine sharedEngine] setEffectsVolume:4.0f];

        }
    }
}

-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

    for( UITouch *touch in touches )
    {

        CGPoint location = [touch locationInView: [touch view]];

        location = [[CCDirector sharedDirector] convertToGL: location];

        [self selectSpriteForTouch:location];
        NSLog(@"touch was detected");
    }   
}

Now I want the sprite to disappear with some animation or any effect. How can I do so?

  • 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-26T04:07:12+00:00Added an answer on May 26, 2026 at 4:07 am

    As an example, this would make your sprite shrink until it disappears then remove it from it’s parent:

    -(void)selectSpriteForTouch:(CGPoint)touchLocation
        ...
        if (CGRectContainsPoint(sprite.boundingBox, touchLocation))
        {
            [sprite runAction:[CCSequence actions:
                [CCScaleTo actionWithDuration:0.4 scale:0],
                [CCCallFuncO actionWithTarget:self selector:@selector(removeSprite:) object:sprite],
                nil]];
                ...//play audio etc
        }
        ....
    }
    
    -(void) removeSprite:(CCSprite*) s
    {
        [s.parent removeChild:s cleanup:YES];
    }
    

    For other actions, try CCMoveTo or CCJumpTo or CCRotateBy. You can run several actions at once, so above the runAction: line I provided, try another [sprite runAction:[CCRotateBy actionWithDuration:0.4 angle:360]]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am experimenting with some new ideas in Cocos2D/Box2D on iPhone. I want to
I'm making a game on iPhone using cocos2d, and I have a question. In
I just finished my new game using Cocos2d (v 0.99.1) for iPhone. Before releasing
I am new to cocos2d and im developing my first iphone game. The requirement
I am new to cocos2d game development. I want to know how to get
I'm new to cocos2d and to iphone development at all. I want to create
I am new to Cocos2d and I am making a game with a SneakyJoystick
I am a programmer new in iphone development. I want to make a game
i want to create a new view in Cocos2d programmatically can you help me
I am new to iOS development. I want to build a simple game with

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.