首页 > 代码库 > cocos2dx3.2几种特效的显示方式

cocos2dx3.2几种特效的显示方式

SpriteFrameCache::getInstance()->addSpriteFramesWithFile("CoinEffectFrame.plist");
		log("CoinEffectFrame.plist");

		Array *animations = Array::createWithCapacity(8);
		char str[100]={0};
		Animation* animation = Animation::create();
		for(int i = 0;i< 8;i++)
		{
			sprintf(str,"coineffect-EffectIn%d.png",i);
			log(str);
			animation->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str));   
		}
		animation->setDelayPerUnit(0.2f);

		AnimationCache::sharedAnimationCache()->addAnimation(animation,"dance");
		
		
		
	
	//cocosbuilder::CCBReader * ccbReader = new cocosbuilder::CCBReader(NodeLoaderLibrary::newDefaultNodeLoaderLibrary());
 //   auto node = ccbReader->readNodeGraphFromFile("CoinEffectFrame.ccbi");
 //   ccbReader->release();
	//addChild(node);
	//node->setPosition(100 ,200);

	spAtlas* atlas = spAtlas_createFromFile("coineffect.atlas", 0);
	spSkeletonJson* json = spSkeletonJson_create(atlas);
	json->scale = 1;
	spSkeletonData* skeletonData = http://www.mamicode.com/spSkeletonJson_readSkeletonDataFile(json,"coineffect.json");

	long first = Function::getInstance()->getTimeuSec();
	auto skeletonCoinNode = spine::NEWSkeletonAnimation::createWithData(skeletonData);
	skeletonCoinNode->setAnimation(0, "EffectIn", false);
    skeletonCoinNode->setPosition(100, 200);
	addChild(skeletonCoinNode);
	long first2 = Function::getInstance()->getTimeuSec();
	auto skeletonCoinNode1 = spine::NEWSkeletonAnimation::createWithData(skeletonData);
	skeletonCoinNode1->setAnimation(0, "EffectIn", false);
    skeletonCoinNode1->setPosition(200, 300);
	addChild(skeletonCoinNode1);

	auto skeletonCoinNode2 = spine::NEWSkeletonAnimation::createWithData(skeletonData);
	skeletonCoinNode2->setAnimation(0, "EffectIn", false);
    skeletonCoinNode2->setPosition(300, 400);
	addChild(skeletonCoinNode2);


	/*Animation* animation1 = AnimationCache::sharedAnimationCache()->animationByName("dance");
	animation1->setRestoreOriginalFrame(true);  
	Animate *action = Animate::create(animation1);  
	auto sprite = Sprite::create();

	addChild(sprite);
	sprite->setPosition(100, 200);
	sprite->runAction(action);
	
	long first2 = Function::getInstance()->getTimeuSec();
	Animation* animation2 = AnimationCache::sharedAnimationCache()->animationByName("dance");
	animation2->setRestoreOriginalFrame(true);  
	Animate *action2 = Animate::create(animation1);  
	auto sprite2 = Sprite::create();
	addChild(sprite2);
	sprite2->setPosition(200, 300);
	sprite2->runAction(action2);*/
	log("time[%ld][%ld]", first2 - first, Function::getInstance()->getTimeuSec() - first2);

//log("time[%ld]", Function::getInstance()->getTimeuSec() - first);

cocos2dx3.2几种特效的显示方式