animation - Syncing sounds with frames inside CCAnimation for cocos2d 2.x* -


how sync sound effects animation (ccanimation)

        nsmutablearray* animationframes = [nsmutablearray array];         [animationframes addobject:[[[ccanimationframe alloc] initwithspriteframe:[titlelayer spriteframeforfile:@"title_startanime01.png"] delayunits:1 userinfo:nil] autorelease]];         [animationframes addobject:[[[ccanimationframe alloc] initwithspriteframe:[titlelayer spriteframeforfile:@"title_startanime02.png"] delayunits:1 userinfo:nil] autorelease]];         [animationframes addobject:[[[ccanimationframe alloc] initwithspriteframe:[titlelayer spriteframeforfile:@"title_startanime03.png"] delayunits:1 userinfo:nil] autorelease]];         [animationframes addobject:[[[ccanimationframe alloc] initwithspriteframe:[titlelayer spriteframeforfile:@"title_startanime04.png"] delayunits:1 userinfo:nil] autorelease]];         [animationframes addobject:[[[ccanimationframe alloc] initwithspriteframe:[titlelayer spriteframeforfile:@"title_startanime05.png"] delayunits:1 userinfo:nil] autorelease]];         [animationframes addobject:[[[ccanimationframe alloc] initwithspriteframe:[titlelayer spriteframeforfile:@"title_startanime06.png"] delayunits:1 userinfo:nil] autorelease]];         ccanimation* animation = [ccanimation animationwithanimationframes:animationframes delayperunit:0.09 loops:1]; 

can add callblock somehow animationframes array?

or work if ccanimationframe had optional callback/delegate when it's activated.

ok have is:

  1. observe notification ccanimationframedisplayednotification. it's called on sprite animated.

  2. in order notification broadcast, dictionary need added ccspriteframe want hook into. added nsdictionary containing spriteframename of each sprite spriteframes since need hook of them, guess dictionary empty well, not nil.

        animationframe = [[[ccanimationframe alloc] initwithspriteframe:[cache spriteframebyname:str] delayunits:1 userinfo:nil] autorelease];     animationframe.userinfo = [nsdictionary dictionarywithobjectsandkeys:str, @"spriteframename", nil];     [animationframes addobject:animationframe];      [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(frameupdatedinbootanimation:) name:ccanimationframedisplayednotification object:null]; 

then catch it

-(void)frameupdatedinbootanimation:(id)hmm {     nslog(@"frameupdatedinbootanimation: %@", hmm);     here 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -