Animation Cocos2d-x我不知道';我不知道如何给动画延迟
现在,我喜欢这个。12个动画同时移动 (对不起,我无法上传图像。所以,我做到了。| ~|是一行,这是3x4矩阵) 但是,我想要这样 例如,左上角1、2、3、…,共有12个面板,十二, 所以,动画移动1、2、3个时间段,而不是相同的时间 像这样 我在网上搜索了一下,加了一些。但是,我无法移动它。我该怎么做呢 这是我的密码Animation Cocos2d-x我不知道';我不知道如何给动画延迟,animation,delay,cocos2d-x,Animation,Delay,Cocos2d X,现在,我喜欢这个。12个动画同时移动 (对不起,我无法上传图像。所以,我做到了。| ~|是一行,这是3x4矩阵) 但是,我想要这样 例如,左上角1、2、3、…,共有12个面板,十二, 所以,动画移动1、2、3个时间段,而不是相同的时间 像这样 我在网上搜索了一下,加了一些。但是,我无法移动它。我该怎么做呢 这是我的密码 CCSprite* maker_sh = CCSprite::create("img/marker_sh.jpg") ; CCAnimation* sh_ani
CCSprite* maker_sh = CCSprite::create("img/marker_sh.jpg") ;
CCAnimation* sh_ani = CCAnimation::create() ;
sh_ani -> setDelayPerUnit(0.05) ;
for(int i = 0 ; i < 24 ; i++)
{
int index = i % 5 ;
int rowIndex = i / 5 ;
sh_ani -> addSpriteFrameWithTexture(maker_sh -> getTexture(), CCRectMake(index * 120, rowIndex * 120, 120, 120)) ;
}
CCAnimate* animate[12] ;
CCAction* rep[12] ;
for(int i = 0 ; i < 12 ; i++)
{
animate[i] = CCAnimate::create(sh_ani) ;
rep[i] = CCRepeatForever::create(animate[i]) ;
}
int cnt = 0 ;
CCSprite* test[12] ;
for(int i = 3 ; i > -1 ; i--)
for(int j = 0 ; j < 3 ; j++)
{
cnt++ ;
test[j + (3 - i) * 3] = CCSprite::createWithTexture(maker_sh -> getTexture(), CCRectMake(0, 0, 120, 120)) ;
test[j + (3 - i) * 3] -> setPosition(ccp(j * 125 + 120, i*125 + 75)) ;
this -> addChild(test[j + (3 - i) * 3]) ;
test[j + (3 - i) * 3] -> runAction(rep[j + (3 - i) * 3]) ;
CCLog("%d", cnt) ;
}
CCSprite*maker_sh=CCSprite::create(“img/marker_sh.jpg”);
CCAnimation*sh_ani=CCAnimation::create();
sh_ani->setDelayPerUnit(0.05);
对于(int i=0;i<24;i++)
{
int指数=i%5;
int rowIndex=i/5;
sh_ani->addSpriteFrameWithTexture(maker_sh->getTexture(),CCRectMake(index*120,rowIndex*120120));
}
cAnimate*动画[12];
c行动*代表[12];
对于(int i=0;i<12;i++)
{
动画[i]=CCAnimate::create(shu ani);
rep[i]=CCRepeatForever::创建(动画[i]);
}
int-cnt=0;
CCSprite*试验[12];
对于(int i=3;i>-1;i--)
对于(int j=0;j<3;j++)
{
cnt++;
test[j+(3-i)*3]=CCSprite::createWithTexture(maker_sh->getTexture(),CCRectMake(0,0,120,120));
测试[j+(3-i)*3]->设定位置(ccp(j*125+120,i*125+75));
这->添加子项(测试[j+(3-i)*3]);
测试[j+(3-i)*3]->运行(rep[j+(3-i)*3]);
CCLog(“%d”,cnt);
}
这不是一个聪明的方法,只希望这能给你一些帮助:)
CCAnimate*动画制作[12];
c行动*代表[12];
浮动间隔=3.f//设置所需的此值
对于(int i=0;i
CCSprite* maker_sh = CCSprite::create("img/marker_sh.jpg") ;
CCAnimation* sh_ani = CCAnimation::create() ;
sh_ani -> setDelayPerUnit(0.05) ;
for(int i = 0 ; i < 24 ; i++)
{
int index = i % 5 ;
int rowIndex = i / 5 ;
sh_ani -> addSpriteFrameWithTexture(maker_sh -> getTexture(), CCRectMake(index * 120, rowIndex * 120, 120, 120)) ;
}
CCAnimate* animate[12] ;
CCAction* rep[12] ;
for(int i = 0 ; i < 12 ; i++)
{
animate[i] = CCAnimate::create(sh_ani) ;
rep[i] = CCRepeatForever::create(animate[i]) ;
}
int cnt = 0 ;
CCSprite* test[12] ;
for(int i = 3 ; i > -1 ; i--)
for(int j = 0 ; j < 3 ; j++)
{
cnt++ ;
test[j + (3 - i) * 3] = CCSprite::createWithTexture(maker_sh -> getTexture(), CCRectMake(0, 0, 120, 120)) ;
test[j + (3 - i) * 3] -> setPosition(ccp(j * 125 + 120, i*125 + 75)) ;
this -> addChild(test[j + (3 - i) * 3]) ;
test[j + (3 - i) * 3] -> runAction(rep[j + (3 - i) * 3]) ;
CCLog("%d", cnt) ;
}
CCAnimate* animate[12];
CCAction* rep[12];
float interval = 3.f;//set this value that you need
for (int i=0; i<12; i++)
{
CCDelayTime* delay = CCDelayTime::create(i*interval);
animate[i] = CCAnimate::create(sh_ani);
CCAction* action = CCRepeatForever::create(animate[i]) ;
rep[i] = CCSequence::create(delay,action);
}