TexturePacker的使用与帧动画效果的实现

本文介绍了TexturePacker的下载地址及其使用方法,同时详细阐述了如何利用TexturePacker来创建帧动画效果,涵盖了从软件操作到实际动画效果实现的全过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

TexturePacker下载地址:http://www.codeandweb.com/texturepacker


TexturePacker的使用

点击Add Sprites按钮添加动画帧


点击publish生成plist文件与打包图片


把生成的plist文件与png文件添加到工程的资源文件目录



帧动画效果的实现

	//动画帧效果

	//1.创建动画帧序列
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("skill/skill26.plist","skill/skill26.png");
	CCArray* frames = CCArray::createWithCapacity(18);//初始化容量为帧数
	CCSpriteFrame* frame;
	for (int i=1; i<=18; ++i)
	{	
		if(i<10){
			//name为未打包图片时的图片原名称
			frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("skill26-0%d.png",i)->getCString());
		}
		else{
			frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("skill26-%d.png",i)->getCString());
		}	
		frames->addObject(frame);
	}
	
	//2.根据动画帧序列创建动画(第二个参数为时间间隔)
	CCAnimation* pAnimSkill44 = CCAnimation::createWithSpriteFrames(frames,0.2f);
	
	//3.根据动画创建动作
	CCAnimate* pSkill44 = CCAnimate::create(pAnimSkill44);

	//4.让精灵执行该动作
	CCSprite* pSprite = CCSprite::create();
	pSprite->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
	this->addChild(pSprite,1);
	pSprite->runAction(CCRepeatForever::create(pSkill44));


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值