How can i set delay for each frame in an animation?
I am using cocos2d library, and now i have a question, how can i set delay for each frame in an animation? In cocos2d, you can only set a duration on animation, but i want to let different frame stay different time, for instance,
frame1 stay 0.1 second
frame2 stay 0.2 second
frame3 stay 0.15 second
How can i do this?
Another question, can the frame be a sprite? Because i want to add more than one images to each frame.
1) store the delay you want to apply (I would put in the detail of you custom frame)
2)do a for(MyCustomView *inst in TheCollectionThatGroupsMyListOfElement)
in which you can happely launch a timer that will animate you View and set the delay of the timer to the value stored in you custom view
I don't know what you mean by sprite ut if you mean a composed view (icon + text + another iamge etc
then just create a custom UIView in wich you build your custom display
i did like that to create a image with some text underneath
hope it helped
jason
__________________
We all have to go down this same road.
You liked it when the ones in front of you helped.
So think about the ones behind you.
---
try, try again, try some more, then ask.
once you asked, continue trying until you find a solution.
and finally make sure you post the solution.
1) store the delay you want to apply (I would put in the detail of you custom frame)
2)do a for(MyCustomView *inst in TheCollectionThatGroupsMyListOfElement)
in which you can happely launch a timer that will animate you View and set the delay of the timer to the value stored in you custom view
I don't know what you mean by sprite ut if you mean a composed view (icon + text + another iamge etc
then just create a custom UIView in wich you build your custom display
i did like that to create a image with some text underneath
hope it helped
jason
Thank you for help. The "sprite" is a word in cocos2d library, you can check it out here: cocos2d-iphone - Google Code
A sprite can flip, scale, move and do other actions, and it can have some children(other sprites).
I want to use the library to improve my development process, it seems that i need to implement sprite animation myself.But i just think if there is a way to do it with cocos2d Animation class.
* Try not to use Cocoa's NSTimers. Instead use cocos2d's own scheduler.
* If you use cocos2d scheduler, you will have:
o automatic pause/resume.
o when the Layer (Scene, Sprite, CocosNode) enters the stage the timer will be automatically activated, and when it leaves the stage it will be automatically deactivated.
o Your target/selector will be called with a delta time
/**********************************************************/
// OK OK OK OK OK
/**********************************************************/
-(id) init
{
if( ! [super init] )
return nil;
// schedule timer
[self schedule: @selector(tick:)];
[self schedule: @selector(tick2:) interval:0.5];
return self;
}
-(void) tick: (ccTime) dt
{
// bla bla bla
}
-(void) tick2: (ccTime) dt
{
// bla bla bla
}
/**********************************************************/
// BAD BAD BAD BAD
/**********************************************************/
// Why BAD ?
// You can't pause the game automagically.
-(void) onEnter
{
[super onEnter];
timer1 = [NSTimer scheduledTimerWithTimeInterval:1/FPS target:self selector:@selector(tick1) userInfo:nil repeats:YES];
timer2 = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(tick2) userInfo:nil repeats:YES];
}
-(void) onExit
{
[timer1 invalidate];
[timer2 invalidate];
[super onExit];
}
-(void) tick
{
// bla bla bla
}
-(void) tick2
{
// bla bla bla
}
it seams to add a few insteresting functionalities that you need when doing 3D programing and you dont want to dig in the code to much.
otherwise as I guessed a sprite is a UIView with extra functionalities ^^
I tend at the moment to try and write the low level stuff by hand and get my own framework of classes and functions going but that a lot of work
maybe if I get round to coco2D you can help me out
best regards
jason
__________________
We all have to go down this same road.
You liked it when the ones in front of you helped.
So think about the ones behind you.
---
try, try again, try some more, then ask.
once you asked, continue trying until you find a solution.
and finally make sure you post the solution.