码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-10-16 17:04:13      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:io   os   ar   for   sp   on   cti   log   ad   

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 = 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几种特效的显示方式

标签:io   os   ar   for   sp   on   cti   log   ad   

原文地址:http://my.oschina.net/ffs/blog/332871

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!