Cocos2d-x_播放帧动画

前端之家收集整理的这篇文章主要介绍了Cocos2d-x_播放帧动画前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
void HelloWorld::mcallBack(CCObject *pSend)
{
	CCSprite *pSpr = (CCSprite *)pSend;
	pSpr->removeFromParentAndCleanup(true);
}

bool HelloWorld::ccTouchBegan(CCTouch *pTouch,CCEvent *pEvent)
{
	CCLOG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

	CCPoint pt = pTouch->getLocation();

	CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("frame_ani/pointer.plist","frame_ani/pointer.png");

	CCSprite *light = CCSprite::create();
	light->setPosition(pt);
	this->addChild(light);

	CCArray *spriteArray = CCArray::create();
	char str[100] = { 0 };
	for (int i = 1; i <= 9; i++)
	{
		sprintf(str,"pointer/%02d.png",i);
		CCSpriteFrame *frame = cache->spriteFrameByName(str);
		spriteArray->addObject(frame);
	}
	CCAnimation *animation = CCAnimation::createWithSpriteFrames(spriteArray,0.05f);
	CCAnimate *animate = CCAnimate::create(animation);
	CCFiniteTimeAction *actSeq = CCSequence::create(animate,CCCallFuncO::create(this,callfuncO_selector(HelloWorld::mcallBack),light),NULL);
	light->runAction(actSeq);

	return true;
}
原文链接:https://www.f2er.com/cocos2dx/343783.html

猜你在找的Cocos2d-x相关文章