当图片大小都一致的情况下直接生成帧动画的类

CCAnimation* SgGameResultAni::CreateKessenEffect(ODEInt32 framecount,string spriteFilename,float var_time)
{

	frameAyyay = CCArray::createWithCapacity(framecount);
	for (int i=1;i<=framecount;++i)
	{
		char filename[40];
		sprintf(filename,spriteFilename.c_str(),i);
		CCTexture2D *fileTexture = CCTextureCache::sharedTextureCache()->addImage(filename);
		CCSpriteFrame *frame =   CCSpriteFrame::createWithTexture(fileTexture,CCRect(0,0,fileTexture->getContentSize().width,fileTexture->getContentSize().height));
		//CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(filename);
		frameAyyay->addObject(frame);
		CCTextureCache::sharedTextureCache()->removeTextureForKey(filename);
	}
	animation = CCAnimation::createWithSpriteFrames(frameAyyay,var_time);
	//animation->retain();
	return animation;
}

</pre><p>使用上面的成员函数生成 animation  然后在使用的地方这样调用</p><p></p><pre code_snippet_id="490189" snippet_file_name="blog_20141020_2_94055" name="code" class="cpp">	CCAnimation *sg_win_ani = sg_ani->CreateKessenEffect(SG_WINEFFECT_FRAME_NUM,IMAGE_PATH_GAME_RESULT_WIN,SG_ANI_VAR_TIME);

		CCAnimate *animate = CCAnimate::create(sg_win_ani);//这里创建了动画的Action
		CCActionInterval* win_seq = (CCActionInterval*)(CCSequence::create( animate,CCDelayTime::create(0.1f),CCRemoveSelf::create(true),pCallbackFun,NULL));
		CCSprite *win_sp = CCSprite::create("win_1.png");
		win_sp->setPosition(pk_exbet_widget.getPosition());
		win_sp->setScale(ui_main_scale);
		addChild(win_sp,9);
		win_sp->runAction(win_seq);


注意:这个如果图片大小不一致就需要对每一帧设置位置了


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值