cocos2d 添加动画几种方式

前端之家收集整理的这篇文章主要介绍了cocos2d 添加动画几种方式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//1.
	ArmatureDataManager::getInstance()->addArmatureFileInfo("Defind/Defind.ExportJson");
	auto armature = Armature::create("Defind");
	armature->setPosition(Point(100,100));
	this->addChild(armature);
	armature->getAnimation()->play("WalkRight");
	auto armature1 = Armature::create("Defind");
	armature1->setPosition(Point(200,100));
	this->addChild(armature1);
	armature1->getAnimation()->play("WalkLeft");
//2.
	auto *rootNode = CSLoader::createNode("Node.csb");
	rootNode->setPosition(Point(100,200));
	ActionTimeline *action = CSLoader::createTimeline("Node.csb");
	action->gotoFrameAndPlay(0,80,true);
	rootNode->runAction(action);
//3.
auto enemy_walker = SpriteFrameCache::getInstance();
	enemy_walker->addSpriteFramesWithFile("Define.plist","Define.png");
	Animation*animation = Animation::create();
	for (int i = 1; i < 4; i++){
		auto spriteFrame = enemy_walker->getSpriteFrameByName(String::createWithFormat("walker%d.png",i)->getCString());
		animation->addSpriteFrame(spriteFrame);
	}
	animation->setDelayPerUnit(0.15f);
	AnimationCache::getInstance()->addAnimation(animation,String::createWithFormat("walker")->getCString());
原文链接:https://www.f2er.com/cocos2dx/344521.html

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