搜索
首页数据库mysql教程spriter动画编辑器的cocos2d

目前我的cocos2d-x编辑器的动画部分接口采用的是spriter动画编辑器提供的接口,spriter动画编辑器虽然简陋,但一般的需求基本上能够满足。可以在http://www.brashmonkey.com/spriter.htm下载,另外cocos2d-x的接口可以在论坛http://www.brashmonkey.com/foru

目前我的cocos2d-x编辑器的动画部分接口采用的是spriter动画编辑器提供的接口,spriter动画编辑器虽然简陋,但一般的需求基本上能够满足。可以在http://www.brashmonkey.com/spriter.htm下载,另外cocos2d-x的接口可以在论坛http://www.brashmonkey.com/forum/viewtopic.php?f=3&t=870下载。

接口导入进来之后,一切都很正常,然而在采用该接口进行开发时,发现有几个比较严重的问题。

问题1:资源采用多文件夹形式存储,渲染效率低

问题2:一个png只能有一个ccsprite,在编辑器是正常的,然而采用论坛那个接口导入到cocos2d-x就有问题。

问题3:精灵不能flip

问题4:不支持scale变换

 

陆续修改了上述4个问题

资源采用Sprite Frame实现

png的bug线性实现,时间复杂度O(1)

flip的实现参考cocos2d-x源码中CCTransitionFlipX的实现——摄像头换位

scale参考angle的变换就OK了

代码如下:

(代码中掺杂了编辑器部分的代码,精力有限,本代码仅供参考)

头文件:

//------------------------------------------------------------------------
//
//	SCMLAnimator : KickStarter project Spriter renderer for cocos2d-x.
//
//	Spriter website : http://www.kickstarter.com/projects/539087245/spriter
//
//	Licensed under the BSD license, see LICENSE in root for details.
// 
//	Copyright (c) 2012 James Hui (a.k.a. Dr.Watson)
// 
//	For latest updates, please visit http://jameshui.com
//
//------------------------------------------------------------------------


#ifndef _CC_SPRITER_X_H_
#define _CC_SPRITER_X_H_

#include <vector>
#include <string>
#include "JEvent.h"
#include "cocos2d.h"
#include "TouchSprite.h"
#include "tinyxml.h"


class CCSpriterX;
#define FILE_SPRITE_SIZE 128

namespace SCMLHelper
{

	struct File
	{
		File();
		~File();

		void Init(TiXmlNode *node);

		int id;
		std::string name;
		float width;
		float height;
		//一个文件可能有多个关联
		cocos2d::CCSprite* sprites[FILE_SPRITE_SIZE];

	};

	class Folder
	{
	public:
		Folder();
		~Folder();
		
		void Init(TiXmlNode *node);
		
		int GetFileCount();
		File *GetFile(int index);

	private:
		int mId;
		std::string mName;

		std::vector <file> mFiles;

	};

	struct ObjectRef
	{
		void Init(TiXmlNode *node);

		int id;
		int timeline;
		int key;
		int z_index;
	};

	struct Object
	{
		void Init(TiXmlNode *node, CCSpriterX *animator, int timelineId);
		
		int folder;
		int file;
		float x;
		float y;
		float angle;
		float scaleX;
		float scaleY;
		float pivot_x;
		float pivot_y;
		int z_index;

		cocos2d::CCSprite *sprite;

	};

	class Key
	{
	public:
		Key();
		~Key();
		
		void Init(TiXmlNode *node, CCSpriterX *animator, int timelineId);
		
		int GetObjectRefCount();
		ObjectRef *GetObjectRef(int index);
		
		int GetObjectCount();
		Object *GetObject(int index);

		float GetTime();

		bool IsSpinCounterClockwise();

	private:
		int mId;
		float mTime;
		bool mSpinCounterClockwise;

		std::vector <object> mObjects;
		std::vector <objectref> mObjectRefs;
		// will have bones later

	};

	class Timeline
	{
	public:
		Timeline();
		~Timeline();

		void Init(TiXmlNode *node, CCSpriterX *animator);
		int GetKeyframeCount();
		Key *GetKeyframe(int index);

	private:
		int mId;
		std::vector <key> mKeyframes;
	};


	class Animation
	{
    public:
		CC_SYNTHESIZE(JEvent *, event, Event);
        CC_SYNTHESIZE(std::string, afterAction, AfterAction);
        CCSpriterX * spr;
	public:
		void Restart();
		Animation(CCSpriterX * spr);
		~Animation();
        
		void Update(float dt);
		void Init(TiXmlNode *node, CCSpriterX *animator);
        
		void Render();

		bool IsDone(); 

	public:
		std::string getName(){return mName;}
	private:
		int mId;
		std::string mName;
		float mLength;
		bool mLooping;
		bool mDone;

		Timeline *mMainline;
		int mCurrKeyframe;

		std::vector <timeline> mTimelines;

		float mTimer;

		cocos2d::CCPoint mPosition;

	};


	class Entity
	{
    private:
        CCSpriterX * spr;
	public:
		Entity(CCSpriterX * spr);
		~Entity();
		void StartWithEvent(const char * name, JEvent * event);
		std::string CurrentAction();
		void Update(float dt);
		void Render();
		void Start(const char * name,const char* _afterAction);
		void SetId(int id);
		void SetName(const char *name);
		void AddAnimation(Animation *animation);

		void NextAnimation();


	private:

		int mId;
		std::string mName;

		std::vector <animation> mAnimations;

		int mCurrAnimation;

	};

}


class CCSpriterX : public TouchSprite
{ 
private:
	struct Pit{
		int fileId;
		int id;
		int folderId;
	};
	Pit fileSprites[FILE_SPRITE_SIZE];
	CC_SYNTHESIZE(ccColor3B, colorX, ColorX);
public:
	CCSpriterX();
	~CCSpriterX(); 
	virtual void setFlipX(bool bFlipX); 
	bool initWithFile(const char *filename); 
	std::string CurrentAction(); 
	virtual void draw(void); 
	virtual void update(float dt); 

	static CCSpriterX * create(const char *filename); 
	cocos2d::CCSprite * getSprite(int folderId, int fileId, int timelineId); 
	void PlayNext(); 
	void PlayWithEvent(const char * name, JEvent * event); 
	void Play(const char* name,const char* _afterAction = 0); 

private:
	std::vector <:folder> mFolders;
	std::vector <:entity> mEntities;

	int mCurrEntity;
};



#endif
</:entity></:folder></animation></timeline></key></objectref></object></file></string></vector>

源文件:
//------------------------------------------------------------------------
//
//	CCSpriterX : KickStarter project Spriter renderer for cocos2d-x.
//
//	Spriter website : http://www.kickstarter.com/projects/539087245/spriter
//
//	Licensed under the BSD license, see LICENSE in root for details.
// 
//	Copyright (c) 2012 James Hui (a.k.a. Dr.Watson)
// 
//	For latest updates, please visit http://jameshui.com
//
//------------------------------------------------------------------------

#include "CCSpriterX.h"
#include "Common.h"
#include "jerror.h" 

USING_NS_CC;


namespace SCMLHelper
{

	///////////////////////////////////////////////////////////////////////////////////

	File::File()
	{
		for(size_t i=0; i<file_sprite_size sprites file:: for i="0;" if null>release();
			}
		}
	}

	void File::Init(TiXmlNode *node)
	{
		TiXmlElement *element = node->ToElement();
		if (element)
		{
			int intValue;
			float floatValue;

			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				id = intValue;
			else
				id = 0;

			name = element->Attribute("name");

			if (element->QueryFloatAttribute("width", &floatValue) == TIXML_SUCCESS)
				width = floatValue;
			else
				width = 0;

			if (element->QueryFloatAttribute("height", &floatValue) == TIXML_SUCCESS)
				height = floatValue;
			else
				height = 0;

			if (name.size()>0)
			{
				//资源全部放到scml目录中!
				std::string path = workPath+gConfig->read<:string>("res")+"/";
				
				//sprite = CCSprite::create((path+"scml/"+name).c_str());
				sprites[0] = CCSprite::createWithSpriteFrameName(name.c_str());
				sprites[0]->retain(); 
			}

		}

	}

	///////////////////////////////////////////////////////////////////////////////////

	Folder::Folder()
		: mId(0)
	{ 
		mFiles.reserve(50); 
	}


	Folder::~Folder()
	{
		int count = mFiles.size();
		for (int i=0;i<count cc_safe_delete mfiles.clear int folder::getfilecount return mfiles.size file index if mfiles null void folder::init tixmlelement node->ToElement();
		if (element)
		{
			int intValue;

			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				mId= intValue;

			mName = element->Attribute("name")==0?".":element->Attribute("name");

			for (TiXmlNode* fileNode = node->FirstChild(); fileNode; fileNode = fileNode->NextSibling())
			{
				File *file = new File();
				file->Init(fileNode);

				mFiles.push_back(file);
			}

		}

	}

	///////////////////////////////////////////////////////////////////////////////////

	void ObjectRef::Init(TiXmlNode *node)
	{
		TiXmlElement *element = node->ToElement();
		if (element)
		{
			int intValue;

			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				id = intValue;
			else
				id = 0;

			if (element->QueryIntAttribute("timeline", &intValue) == TIXML_SUCCESS)
				timeline = intValue;
			else
				timeline = 0;

			if (element->QueryIntAttribute("key", &intValue) == TIXML_SUCCESS)
				key = intValue;
			else
				key = 0;

			if (element->QueryIntAttribute("z_index", &intValue) == TIXML_SUCCESS)
				z_index = intValue;
			else
				z_index = 0;

		}
	}


	///////////////////////////////////////////////////////////////////////////////////

	void Object::Init(TiXmlNode *node, CCSpriterX *animator, int timelineId)
	{
		sprite = NULL;

        float scaleFactor = CCDirector::sharedDirector()->getContentScaleFactor();
        
		TiXmlElement *element = node->ToElement();
		if (element)
		{
			int intValue;
			float floatValue;

			if (element->QueryIntAttribute("folder", &intValue) == TIXML_SUCCESS)
				folder = intValue;
			else
				folder = 0;

			if (element->QueryIntAttribute("file", &intValue) == TIXML_SUCCESS)
				file = intValue;
			else
				file = 0;

			if (element->QueryFloatAttribute("x", &floatValue) == TIXML_SUCCESS)
				x = floatValue/scaleFactor;
			else
				x = 0;

			if (element->QueryFloatAttribute("y", &floatValue) == TIXML_SUCCESS)
				y = floatValue/scaleFactor;
			else
				y = 0;

			if (element->QueryFloatAttribute("angle", &floatValue) == TIXML_SUCCESS)
				angle = floatValue;
			else
				angle = 0;

			if (element->QueryFloatAttribute("scale_x", &floatValue) == TIXML_SUCCESS)
				scaleX = floatValue;
			else
				scaleX = 1;
			if(scaleX QueryFloatAttribute("scale_y", &floatValue) == TIXML_SUCCESS)
				scaleY = floatValue;
			else
				scaleY = 1;

			if (element->QueryFloatAttribute("pivot_x", &floatValue) == TIXML_SUCCESS)
				pivot_x = floatValue;
			else
				pivot_x = 0;

			if (element->QueryFloatAttribute("pivot_y", &floatValue) == TIXML_SUCCESS)
				pivot_y = floatValue;
			else
				pivot_y = 1;

			if (element->QueryIntAttribute("z_index", &intValue) == TIXML_SUCCESS)
				z_index = intValue;
			else
				z_index = 0; 

			sprite = animator->getSprite(folder, file, timelineId);
		}
	}
	///////////////////////////////////////////////////////////////////////////////////

	Key::Key()
		: mId(0)
		, mTime(0)
		, mSpinCounterClockwise(true)
	{ 
		mObjects.reserve(50);
		mObjectRefs.reserve(50); 
	}


	Key::~Key()
	{
		int count = mObjects.size();
		for (int i=0;i<count cc_safe_delete mobjects.clear count="mObjectRefs.size();" for i="0;i<count;i++)" mobjectrefs.clear int key::getobjectrefcount return mobjectrefs.size objectref index if mobjectrefs null key::getobjectcount mobjects.size object mobjects float key::gettime mtime bool key::isspincounterclockwise mspincounterclockwise void key::init ccspriterx timelineid tixmlelement node->ToElement();
		if (element)
		{
			int intValue;
			float floatValue;
			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				mId = intValue;

			float time = 0;
			if (element->QueryFloatAttribute("time", &floatValue) == TIXML_SUCCESS)		// was in milliseconds, convert to seconds instead
				time = floatValue/1000.0f;
			mTime = time;

			if (element->QueryIntAttribute("spin", &intValue) == TIXML_SUCCESS)
				mSpinCounterClockwise = !(intValue == -1);

			for (TiXmlNode* objNode = node->FirstChild(); objNode; objNode = objNode->NextSibling())
			{
				element = objNode->ToElement();
				const char *tabObj = element->Value();

				if (strcmp(tabObj, "object_ref")==0)
				{
					ObjectRef *ref = new ObjectRef();
					ref->Init(objNode);
					mObjectRefs.push_back(ref);

				}
				else if (strcmp(tabObj, "object")==0)
				{
					Object *obj = new Object();
					obj->Init(objNode, animator, timelineId);

					mObjects.push_back(obj);
				}
			}
		}

	}


	///////////////////////////////////////////////////////////////////////////////////
	
	Timeline::Timeline()
		: mId(0)
	{
		mKeyframes.reserve(50);
	}


	Timeline::~Timeline()
	{
		int count = mKeyframes.size();
		for (int i=0;i<count cc_safe_delete int timeline::getkeyframecount return mkeyframes.size key index if mkeyframes null void timeline::init ccspriterx intvalue tixmlelement node->ToElement();

		if (element)
		{
			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				mId = intValue;

			for (TiXmlNode* keyNode = node->FirstChild(); keyNode; keyNode = keyNode->NextSibling())
			{
				element = keyNode->ToElement();
				if (element)
				{
					Key *keyframe = new Key();

					keyframe->Init(keyNode, animator, mId);

					mKeyframes.push_back(keyframe);
				}
			}

		}

	}

	///////////////////////////////////////////////////////////////////////////////////

	Animation::Animation(CCSpriterX * _spr)
		: mId(0)
        , spr(_spr)
		, mCurrKeyframe(0)
		, mMainline(NULL)
		, mDone(false)
		, mTimer(0)
		,event(0),afterAction("")
	{
		mTimelines.reserve(50);

	}

	Animation::~Animation()
	{
		int count = mTimelines.size();
		for (int i=0;i<count cc_safe_delete mtimelines.clear void animation::init ccspriterx int intvalue float floatvalue tixmlelement node->ToElement();

		if (element)
		{
			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				mId = intValue;

			mName = element->Attribute("name");

			if (element->QueryFloatAttribute("length", &floatValue) == TIXML_SUCCESS)
				mLength = floatValue/1000.0f;							// was in milliseconds, convert to seconds instead

			const char *looping = element->Attribute("looping");		// was set to "false" in alpha, but in fact looping all the time
			mLooping = true;

			for (TiXmlNode* lineNode = node->FirstChild(); lineNode; lineNode = lineNode->NextSibling())
			{
				element = lineNode->ToElement();

				const char *tabLine = element->Value();
				if (strcmp(tabLine, "mainline")==0)						// 1 mainline only
				{
					mMainline = new Timeline();
					mMainline->Init(lineNode, animator);

				}
				else if (strcmp(tabLine, "timeline")==0)
				{
					Timeline *timeline = new Timeline();
					timeline->Init(lineNode, animator);

					mTimelines.push_back(timeline);
				}
			}
		}

	}


	bool Animation::IsDone()
	{
		return mDone;

	}

	void Animation::Restart()
	{ 
		mDone = false;
		mTimer = 0;
		mCurrKeyframe = 0;

	} 
 
	float lerp(float a, float b, float t){
		return a+(b-a)*t;
	}

	void Animation::Update(float dt)
	{

		mTimer += dt;
		if (mTimer >= mLength)
		{
			mDone = true;

			Restart();			// always looping for now

		}

		int count = mMainline->GetKeyframeCount();
		Key *keyframe = mMainline->GetKeyframe(mCurrKeyframe);
		float currTime = keyframe->GetTime();

		Key *keyframeNext = NULL;

		int next = mCurrKeyframe+1;

		if (next > count-1)		// looping
			next = 0;

		keyframeNext = mMainline->GetKeyframe(next);

		if (keyframeNext)
		{
			float nextTime = keyframeNext->GetTime();
			if (next == 0)
				nextTime = mLength;

			if (mTimer >= nextTime)
			{

				mCurrKeyframe = next;

				keyframe = keyframeNext;
				currTime = keyframe->GetTime();

				next = mCurrKeyframe+1;
				if (next > count-1)				// looping
					next = 0;

				keyframeNext = mMainline->GetKeyframe(next);
				if (keyframeNext == NULL)
					return;

				nextTime = keyframeNext->GetTime();
				if (next == 0)
					nextTime = mLength;

			}


			float t = (mTimer-currTime)/(nextTime-currTime);

			int count = keyframe->GetObjectRefCount();
			for (int i=0;i<count objectref keyframe->GetObjectRef(i);

				ObjectRef *refNext = keyframeNext->GetObjectRef(i);

				if (ref && refNext)
				{

					Key *keyRef = mTimelines[ref->timeline]->GetKeyframe(ref->key);
					Object *obj = keyRef->GetObject(0);									// should be only 1 object

					Key *keyRefNext = mTimelines[refNext->timeline]->GetKeyframe(refNext->key);
					Object *objNext = keyRefNext->GetObject(0);

					float x = lerp(obj->x, objNext->x, t); 
					float y = lerp(obj->y, objNext->y, t);

					float scaleX = lerp(obj->scaleX, objNext->scaleX, t);
					float scaleY = lerp(obj->scaleY, objNext->scaleY, t);

					float angle = objNext->angle-obj->angle;
					if (keyRef->IsSpinCounterClockwise())
					{
						if (angle angle+360)-obj->angle;
					}
					else
					{
						if (angle > 0)
						{
							angle = (objNext->angle-360)-obj->angle;
						}

					}

					if (ref->timeline != refNext->timeline)	
						t = 0;

					angle = obj->angle+(angle)*t;

					if (angle >= 360)
						angle -= 360;

					float px = obj->pivot_x+(objNext->pivot_x-obj->pivot_x)*t;
					float py = obj->pivot_y+(objNext->pivot_y-obj->pivot_y)*t;

					CCPoint newPos = ccp(x, y);
					obj->sprite->setPosition(newPos);
					obj->sprite->setRotation(-angle);
					obj->sprite->setScaleX(scaleX);
					obj->sprite->setScaleY(scaleY);
					obj->sprite->setAnchorPoint(ccp(px, py));

				}


			}
		}


	}



	void Animation::Render()
	{
		Key *keyframe = mMainline->GetKeyframe(mCurrKeyframe);

		int count = keyframe->GetObjectRefCount();
		for (int i=0;i<count objectref keyframe->GetObjectRef(i);

			if (ref)
			{

				Key *keyRef = mTimelines[ref->timeline]->GetKeyframe(ref->key);
				Object *obj = keyRef->GetObject(0);									// should be only 1 object
				obj->sprite->setColor(spr->getColorX());
				obj->sprite->visit();
			}
		}

	}


	///////////////////////////////////////////////////////////////////////////////////

	Entity::Entity(CCSpriterX * _spr)
		: mCurrAnimation(0)
		, mId(0)
        , spr(_spr)
	{
		mAnimations.reserve(50);
	};


	Entity::~Entity()
	{
		int count = mAnimations.size();
		for (int i=0;i<count cc_safe_delete manimations.clear void entity::update dt animation manimations animation->Update(dt);
	}

    std::string Entity::CurrentAction()
    {
        return mAnimations[mCurrAnimation]->getName();
    }
	
	void Entity::StartWithEvent(const char * name, JEvent * event)
	{
		for(size_t i=0; i<manimations.size if>getName() == std::string(name)){
				mCurrAnimation = i;
				mAnimations[i]->setEvent(event);
				mAnimations[i]->Restart();
			}
		}
	}

    void Entity::Start(const char * name, const char * _afterAction)
	{
		for(size_t i=0; i<manimations.size if>getName() == std::string(name)){
				mCurrAnimation = i;
				mAnimations[i]->setAfterAction(_afterAction);
				mAnimations[i]->Restart();
			}
		}
	}


	void Entity::Render()
	{
		Animation *animation = mAnimations[mCurrAnimation];
		animation->Render();

	}


	void Entity::NextAnimation()
	{
		mCurrAnimation++;
		if (mCurrAnimation >= (int)mAnimations.size())
			mCurrAnimation = 0;

		Animation *animation = mAnimations[mCurrAnimation];
		animation->Restart();

	}


	void Entity::SetId(int id)
	{
		mId = id;

	}


	void Entity::SetName(const char *name)
	{
		mName = name;

	}


	void Entity::AddAnimation(Animation *animation)
	{
		mAnimations.push_back(animation);
	}

}

///////////////////////////////////////////////////////////////////////////////////

using namespace SCMLHelper;


CCSpriterX::CCSpriterX()
{
	mFolders.reserve(50);
	mEntities.reserve(50);
	for(int i=0; i<file_sprite_size filesprites ccspriterx:: ccspriterx char new animator->type = SCML;
	animator->m_state = kLivingStateUngrabbed;
	if (animator && animator->initWithFile(filename))
	{
		//由于是动画层,没有大小,这里设置大小,使之能够拾取
		animator->setContentSize(CCSizeMake(100, 100));
		animator->autorelease();
		return animator;
	}
	CC_SAFE_DELETE(animator);
	return NULL;
}


void CCSpriterX::update(float dt)
{
	if (dt > 0.0167f)
		dt = 0.0167f;

	Entity *entity = mEntities[mCurrEntity];
	entity->Update(dt); 
}


void CCSpriterX::draw(void)
{
	Entity *entity = mEntities[mCurrEntity];
	entity->Render();
}
std::string CCSpriterX::CurrentAction()
{
    Entity *entity = mEntities[mCurrEntity];
    return entity->CurrentAction();
}

void CCSpriterX::PlayWithEvent(const char * name, JEvent * event)
{
	Entity *entity = mEntities[mCurrEntity];
	entity->StartWithEvent(name, event);
}

void CCSpriterX::Play(const char* name, const char * _afterAction)
{ 
	Entity *entity = mEntities[mCurrEntity];
	entity->Start(name, _afterAction == 0?"":_afterAction);
}

void CCSpriterX::PlayNext()
{
	Entity *entity = mEntities[mCurrEntity];
	entity->NextAnimation();
}

CCSprite *CCSpriterX::getSprite(int folderId, int fileId, int timelineId)
{
	if (folderId GetFile(fileId);

			if (file){
				int id = this->fileSprites[timelineId].id;
				if(id == -1){
					for(int i=0; i<file_sprite_size if fileid filesprites folderid id>sprites[id] == 0){
					file->sprites[id] = CCSprite::createWithSpriteFrameName(file->name.c_str());
					file->sprites[id]->retain();
				}
				return file->sprites[id];
			}
				
		}
	}

	return NULL;
}

void CCSpriterX::setFlipX(bool bFlipX)
{
	if(bFlipX != m_bFlipX){
		float ex,ey,ez;
		this->getCamera()->getEyeXYZ(&ex, &ey, &ez);
		this->getCamera()->setEyeXYZ(ex, ey, bFlipX?-fabs(ez):fabs(ez));
		this->m_bFlipX = bFlipX;
	}
}

bool CCSpriterX::initWithFile(const char *filename)
{
	char cfilename[256];
	strcpy(cfilename, filename);
	string name = strtok(cfilename, ".");
	string suffix = strtok(cfilename, ".");  

	mCurrEntity = 0;

	unsigned long filesize;
	string path = workPath+gConfig->read<string>("res")+"/"+filename;
	char *buffer = (char *)CCFileUtils::sharedFileUtils()->getFileData(path.c_str(), "rb", &filesize);
	
	if (buffer == NULL)
		return false;

	//加载大图
	string sfplist = workPath+gConfig->read<string>("res")+"/scml/"+name+".plist";
	string sfpng = workPath+gConfig->read<string>("res")+"/scml/"+name+".png";
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(sfplist.c_str(), sfpng.c_str());

	TiXmlDocument doc;

	doc.Parse(buffer);

	TiXmlNode *root = doc.FirstChild("spriter_data"); 
	if (root)
	{
		
		TiXmlElement *element = root->ToElement();

		const char *version = element->Attribute("scml_version");
		const char *generator = element->Attribute("generator");
		const char *generatorVersion = element->Attribute("generator_version");

			

		for (TiXmlNode* entityNode = root->FirstChild(); entityNode; entityNode = entityNode->NextSibling())
		{
			element = entityNode->ToElement();

			if (element)
			{
				const char *tab = element->Value();

				if (strcmp(tab, "folder")==0)
				{
					Folder *folder = new Folder();

					folder->Init(entityNode);

					mFolders.push_back(folder);

				}
				else if (strcmp(tab, "entity")==0)
				{
					int intValue;
					Entity *entity = new Entity(this);

					if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
						entity->SetId(intValue);

					entity->SetName(element->Attribute("name"));

					for (TiXmlNode* animationNode = entityNode->FirstChild(); animationNode; animationNode = animationNode->NextSibling())
					{
						Animation *animation = new Animation(this);
						animation->Init(animationNode, this);

						entity->AddAnimation(animation);

					}

					mEntities.push_back(entity);
				}
			}
		}
	}

	CC_SAFE_DELETE_ARRAY(buffer);

	this->scheduleUpdate();

	return true;

}
	
</string></string></string></file_sprite_size></file_sprite_size></manimations.size></manimations.size></count></count></count></count></count></count></count></:string></file_sprite_size>


声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
如何加速Windows 11中的动画效果:2种方法解析如何加速Windows 11中的动画效果:2种方法解析Apr 24, 2023 pm 04:55 PM

当微软推出Windows11时,它带来了许多变化。其中一项更改是增加了用户界面动画的数量。一些用户想要改变事物的出现方式,他们必须想办法去做。拥有动画让用户感觉更好、更友好。动画使用视觉效果使计算机看起来更具吸引力和响应能力。其中一些包括几秒钟或几分钟后的滑动菜单。计算机上有许多动画会影响PC性能、减慢速度并影响您的工作。在这种情况下,您必须关闭动画。本文将介绍用户可以提高其在PC上的动画速度的几种方法。您可以使用注册表编辑器或您运行的自定义文件来应用更改。如何提高Windows11动画的

如何使用Vue实现打字机动画特效如何使用Vue实现打字机动画特效Sep 19, 2023 am 09:33 AM

如何使用Vue实现打字机动画特效打字机动画是一种常见且引人注目的特效,常用于网站的标题、标语等文字展示上。在Vue中,我们可以通过使用Vue自定义指令来实现打字机动画效果。本文将详细介绍如何使用Vue来实现这一特效,并提供具体的代码示例。步骤1:创建Vue项目首先,我们需要创建一个Vue项目。可以使用VueCLI来快速创建一个新的Vue项目,或者手动在HT

如何在 Windows 11 中禁用动画如何在 Windows 11 中禁用动画Apr 16, 2023 pm 11:34 PM

MicrosoftWindows11中包含多项新特性和功能。用户界面已更新,公司还引入了一些新效果。默认情况下,动画效果应用于控件和其他对象。我应该禁用这些动画吗?尽管Windows11具有视觉上吸引人的动画和淡入淡出效果,但它们可能会导致您的计算机对某些用户来说感觉迟钝,因为它们会为某些任务增加一点延迟。关闭动画以获得更灵敏的用户体验很简单。在我们看到对操作系统进行了哪些其他更改后,我们将引导您了解在Windows11中打开或关闭动画效果的方法。我们还有一篇关于如何在Windows

主线动画《明日方舟:冬隐归路》定档 PV 公布,10 月 7 日上线主线动画《明日方舟:冬隐归路》定档 PV 公布,10 月 7 日上线Sep 23, 2023 am 11:37 AM

本站需要重新写作的内容是:9需要重新写作的内容是:月需要重新写作的内容是:23需要重新写作的内容是:日消息,动画剧集《明日方舟》的第二季主线剧《明日方舟:冬隐归路》公布定档需要重新写作的内容是:PV,将于需要重新写作的内容是:10需要重新写作的内容是:月需要重新写作的内容是:7需要重新写作的内容是:日需要重新写作的内容是:00:23需要重新写作的内容是:正式上线,点此进入主题官网。需要重新写作的内容是:本站注意到,《明日方舟:冬隐归路》是《明日方舟:黎明前奏》的续作,剧情简介如下:为阻止感染者组

原来利用纯CSS也能实现文字轮播与图片轮播!原来利用纯CSS也能实现文字轮播与图片轮播!Jun 10, 2022 pm 01:00 PM

怎么制作文字轮播与图片轮播?大家第一想到的是不是利用js,其实利用纯CSS也能实现文字轮播与图片轮播,下面来看看实现方法,希望对大家有所帮助!

怎样在Windows 11的测试设置中启用图标动画?怎样在Windows 11的测试设置中启用图标动画?Apr 24, 2023 pm 11:28 PM

微软正在Windows11中试验新的任务栏动画,这是这家软件巨头正在进行的另一项新测试。这一次在设置应用程序中,当您单击相应部分时,图标会显示动画。以下是如何在Windows11中为“设置”应用启用图标动画。您可以在Windows11中看到特殊的动画和动画效果。例如,当您最小化和最大化设置应用程序或文件资源管理器时,您会注意到动画。说到图标,当您最小化窗口时,您会看到一个图标会向下弹起,而在您最大化或恢复时,它会弹起。Windows11设置可能会新收到左侧显示的导航图标动画,这是您

Midjourney 5.2震撼发布!原画生成3D场景,无限缩放无垠宇宙Midjourney 5.2震撼发布!原画生成3D场景,无限缩放无垠宇宙Jun 25, 2023 pm 06:55 PM

Midjourney和StableDiffusion,已经卷到没边了!几乎在StableDiffusionXL0.9发布的同一时间,Midjourney宣布推出了5.2版本。此次5.2版本最亮眼的更新在于zoomout功能,它可以无限扩展原始图像,同时保持跟原始图像的细节相同。用zoomout做出的无垠宇宙动画,直接让人震惊到失语,可以说,Midjourney5.2看得比詹姆斯韦伯太空望远镜还要远!这个极其强大的功能,可以创造出非常神奇的图片,甚至还能被用来拍摄毫无破绽的高清变焦视频!这个「核弹

Vue中如何实现图片的闪烁和旋转动画?Vue中如何实现图片的闪烁和旋转动画?Aug 17, 2023 pm 12:37 PM

Vue中如何实现图片的闪烁和旋转动画Vue.js是目前非常流行的前端框架之一,它提供了强大的工具来管理和展示页面中的数据。在Vue中,我们可以通过添加CSS样式和动画来使元素产生各种各样的效果。本文将介绍如何使用Vue和CSS来实现图片的闪烁和旋转动画。首先,我们需要准备一张图片,可以是本地的图片文件或者网络上的图片地址。我们将使用&lt;img&gt;标

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版