0

I ceated the CCBFile in Sprite Builder and added in a main scene, now when i run the project that CCBFile animation start automatically. I want to start or call it after some delay... any idea?

here is my code...

@implementation MainScene {
CCPhysicsNode *_physicsNode;
CCNode *playerbackwardshort;

}

// is called when CCB file has completed loading
- (void)didLoadFromCCB {

//For Delay
[self performSelector:@selector(Upgrade)  withObject:nil afterDelay:0.6];
}


-(void)Upgrade{
CCBAnimationManager* am = self.userObject;
[am runAnimationsForSequenceNamed:@"playerbackwardshort"];
}
Nasir Khan
  • 37
  • 12

1 Answers1

1

The CCBAnimationManager is used for this. Let's say that you named your animation 'AnimationTest`. To stop it from running automatically, there's an option for it in the timeline properties (see here)

// in the loaded ccb file's class
CCBAnimationManager* animationManager = self.userObject;
[animationManager runAnimationsForSequenceNamed:@"AnimationTest"];
Alexander
  • 8,117
  • 1
  • 35
  • 46
  • The program stops on this line [animationManager runAnimationsForSequenceNamed:@"backwardshort"]; – Nasir Khan Jun 09 '14 at 06:15
  • Would you care to investigate the problem? Why does it stop, at what line of the function call does it stop? – Alexander Jun 09 '14 at 10:38
  • lets start it step by step 1. created new sprite file in sprite builder. 2. Set no. of pictures for animation. 3. add that sprite to the main scene. 4. Assign a variable "_playerbackwardshort" to that ccbFile. 5. Now open Xcode. 6. in implementation (CCNode *_playerbackwardshort;) 7. in - (void)didLoadFromCCB method add these two line you posted with replacement of animationTest to _playerbackwardshort. – Nasir Khan Jun 09 '14 at 11:03
  • Is your animation timeline named `_playerbackwardshort `? Because if it isn't, animation manager would not be able to load it. – Alexander Jun 09 '14 at 14:24
  • i assign it "Doc Root Var" with name "_playerbackwardshort", can u please guide me step by step... i tried many methods like custom class of that animation with name "player" added it in AppDelegate "[CCBReader load:@"Player"];" then added your line but it gives error "Warning: File not found: Player.ccbi" so please guide me step by step with any of your example in which you manage your sprite builder animation in xcode. Thanks – Nasir Khan Jun 10 '14 at 06:56
  • Check out [this tutorial](https://www.makegameswith.us/tutorials/getting-started-with-spritebuilder/sprite-animation-spritebuilder/), read the 'Unsynchronize the animations' section. – Alexander Jun 11 '14 at 05:23