标签:创建 tde public return cto private for blog tor
1.多文件帧序列动画
TrademarkAnimation.h
#ifndef __TRADEMARK_ANIMATION_H__ #define __TRADEMARK_ANIMATION_H__ #include "cocos2d.h" USING_NS_CC; class TrademarkAnimation : public cocos2d::CCLayer{ private: Animate* createAnimate(); public : ~TrademarkAnimation(); virtual bool init(); CREATE_FUNC(TrademarkAnimation); }; #endif
TrademarkAnimation.cpp
#include "TrademarkAnimation.h" bool TrademarkAnimation::init(){ if(!CCLayer::init())return false; Sprite* runSp=Sprite::create(); runSp->setPosition(Point(200,200)); this->addChild(runSp); runSp->runAction(createAnimate()); return true; } Animate* TrademarkAnimation::createAnimate(){ int totalFrames=319; SpriteFrame* frame=NULL; Vector<SpriteFrame*> frameVec; for(int i=1;i<=totalFrames;i++){ //tdmark/tdmark0001.png....tdmark/tdmark0319.png frame=SpriteFrame::create(StringUtils::format("tdmark/tdmark%04d.png",i),Rect(0,0,354,270)); frameVec.pushBack(frame); } Animation* animation=Animation::createWithSpriteFrames(frameVec); animation->setLoops(-1); animation->setDelayPerUnit(0.04f);//: 1/帧频 Animate* action=Animate::create(animation); return action; } TrademarkAnimation::~TrademarkAnimation(){ }
标签:创建 tde public return cto private for blog tor
原文地址:http://www.cnblogs.com/kingBook/p/6104597.html