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

  • Home
  • SEARCH
  • 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 8079953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:16:20+00:00 2026-06-05T16:16:20+00:00

I want to respawn enemy sprites based on a timer any suggestions would be

  • 0

I want to respawn enemy sprites based on a timer any suggestions would be appreciated.
Would be great if you show me some code examples.

   -(void)addEnemyAtX:(int)x y:(int)y {
  CCSprite *enemy = [CCSprite spriteWithFile:@"enemy1.png"];
  enemy.position = ccp(x, y);
  [self addChild:enemy];
  [self animateEnemy: enemy];}


  - (void) enemyMoveFinished:(id)sender {
CCSprite *enemy = (CCSprite *)sender;

    [self animateEnemy: enemy];
 }// a method to move the enemy 10 pixels toward the player
 - (void) animateEnemy:(CCSprite*)enemy
    {
    // speed of the enemy
     ccTime actualDuration = 0.3;

     // Create the actions
        id actionMove = [CCMoveBy actionWithDuration:actualDuration
                                                    position:ccpMult(ccpNormalize(ccpSub(player.position,enemy.position)), 10)];
     id actionMoveDone = [CCCallFuncN actionWithTarget:self
                                         selector:@selector(enemyMoveFinished:)];
          [enemy runAction:
                 [CCSequence actions:actionMove, actionMoveDone, nil]];



         }
  • 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-06-05T16:16:21+00:00Added an answer on June 5, 2026 at 4:16 pm

    I think you should learn the basics of Cocos2D first 😉 It’s pretty well covered in the book “Learning Cocos2D” – I recommend it!
    Nevertheless here is the line of code you want, I doubt though, that it is useful 😉

    action = [CCSpawn actions:
              [CCAnimate actionWithAnimation:animation
    break;
    restoreOriginalFrame:NO],
    [CCMoveTo actionWithDuration:2.4f
     position:ccp([self position].x +
     nil];
    xPositionOffSet,
    [self position].y)],
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Want to convert some C# code for RX to F# code. The following C#
Want to code a key pad for an calculator. What I want to make
want to make a check in my installer before starting installation if any other
Want to attach an Event Handler/Listener to some links using the delegate() method, but
want to share a link from my application in windows phone 7. Any one
Want to mimic php code in c# . I want to Capture raw image
want to show a error message as a result of a form action. For
want to query below xml <courseList filedUnder=Courses> <category code=4wd title=4wd Operation> <product code=lr title=4wd
Want to find piece of the code, written in python, which adds a new
Want to know, having a class without any annotation, how the jaxb unmarshall the

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.