cocos2d-xcocos2d js armaturee 怎么获取最后的帧

cocos2d-x - 随笔分类 - 一枚程序 - 博客园
随笔分类 - cocos2d-x
摘要: #include &HelloWorldScene.h&//物理引擎标识 int ball1Mask = 1 getPhysicsWorld()-&setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); // 'layer' is an au...
摘要: #define RAND_LIMIT 32767/// Random number in range [-1,1]inline float32 RandomFloat(){ float32 r = (float32)(std::rand() & (RAND_LIMIT)); ...
摘要: class EnemyBase : public Sprite { public: virtual bool init() CREATE_FUNC(EnemyBase); Animation* createAnimation(std::s...
摘要: //让精灵动起来,并改变方向void EnemyBase::changeDirection(float dt) { auto curr = currPoint(); if(curr-&getPositionX() & this-&getPosition().x ) {...
摘要: //给精灵创建帧动画Animation* EnemyBase::createAnimation(std::string prefixName, int framesNum, float delay) { // 1 Vector animF // 2 fo...
摘要: function UIBagController:initItemView( ) -- 获取面板 self.panelCenter = tolua.cast(UIHelper:seekWidgetByName(self.owner, &Panel_Center&), &Layout&);...
摘要: --local MainSceneConfig = require &res.scripts.configs.MainSceneConfig& -- 暂时添加一个临时配置文件--require &res.scripts.scenes.MainScene&-- 加载事件OnLoadingStart = &OnLoadingStart&;OnLoadingProcess = &OnLoadingProcess&;OnLoadingEnd = &OnLoadingEnd&;-- 加载类型SOUNDTY
摘要: CCArmatureDataManager::sharedArmatureDataManager()-&addArmatureFileInfoAsync(&armature/robot.png&, &armature/robot.plist&, &armature/robot.xml&, this, NULL);CCArmatureDataManager::sharedArmatureDataManager()-&addArmatureFileInfoAsync(&armature/hero.ExportJson
摘要: CCSprite* pImgBg = CCSprite::create(&1.png&); pImgBg-&setPosition(ccp(CCDirector::sharedDirector()-&getWinSize().width / 2, CCDirector::sharedDirector()-&getWinSize().height / 2)); this-&addChild(pImgBg); CCActionInterval *action = CCShatteredTiles3D::create(0.2f, CCSizeMake(16
摘要: #include &Common.h&#ifdef WIN32#include #else#include #include #endif#include &iconvstring/IconvString.h&#include &iconvstring/IconvStringEx.h&USING_NS_CC;namespace{ int MonthWeekDay [10][12][1] = { // 2013 { {0}, {0}, {0}, {0}, {0}, {0}, {1}, {4}, {7}, {2}, {5}, {7} ..
摘要: // 创建cat精灵 CCSprite* cat = CCSprite::create(&Image\\grossini.png&); //change the transform anchor point to 0,0 (optional) cat-&setAnchorPoint( ccp(0,0) ); //创建 background 精灵最为背景 CCSprite* background = CCSprite::create(&Image\\background.png&); // scale the image (optional) bac
摘要: CCArmatureDataManager::sharedArmatureDataManager()-& addArmatureFileInfo(&armature\\Cowboy0.png&, &armature\\Cowboy0.plist&, &armature\\Cowboy.ExportJson&); for (int i = 0; i getAnimation()-&playWithIndex(0); armature-&setPosition(ccp(CCDirector::sharedDirector
摘要: 这个例子主要是用cocos2d-x引擎自带的资源cocos2d-x-2.2.2\samples\Cpp\TestCpp\Resources\armature新建工程之后#include &HelloWorldScene.h&#include &cocos-ext.h&USING_NS_CC;USING_NS_CC_EXT;CCScene* HelloWorld::scene(){ // 'scene' is an autorelease object CCScene *scene = CCScene::create(); // '
摘要: CCRenderTexture,它允许你来动态创建纹理,并且可以在游戏中重用这些纹理。 使用CCRenderTexture非常简单 – 你只需要做以下5步就行了:创建一个新的CCRenderTexture. 这里,你可以指定将要创建的纹理的宽度和高度。.调用CCRenderTexture:begin. 这个方法会启动OpenGL,并且接下来,任何绘图的命令都会渲染到CCRenderTexture里面去,而不是画到屏幕上。绘制纹理. 你可以使用原始的OpenGL调用来绘图,或者你也可以使用cocos2d对象里面已经定义好的visit方法。(这个visit方法就会调用一些opengl命令来绘制c.
摘要: /** * CCDictionary is a class like NSDictionary in Obj-C . * * @note Only the pointer of CCObject or its subclass can be inserted to CCDictionary. * @code * // Create a dictionary, return an autorelease object. * CCDictionary* pDict = CCDictionary::create(); * * // Insert objects to dictionary...
摘要: CCScale9Sprite* pBGPicFrame = CCScale9Sprite::create((g_ImgPath + &23.png&).c_str()); CC_ERROR(pBGPicFrame, &【CActiveSetInfoLayer::ShowRight】pBGPicFrame is null !&); pBGPicFrame-&setContentSize(CCSizeMake(280, 779)); pBGPicFrame-&setAnchorPoint(ccp(0, 0)); pBGPicFrame-&s
摘要: //-----------------------------------------------------------------//@file gameui/Module/MdGraySprite.h//@date //@desc 精灵灰化:shader//@action UI组件//-----------------------------------------------------------------#ifndef __GAMEUI_MODULE_MDGRAYSPRITE_H__#define __GAMEU...
摘要: #ifndef __FIGTH_H__#define __FIGTH_H__#include &cocos-ext.h&#include &include/ILayer.h&#include &kernel/BaseDefine.h&USING_NS_CC;USING_NS_CC_EXT;class CFigthLayer : public CBaseLayer{private: enum E_FIGHT { FIGHT_NIL = 0, FIGHT_NORTH = 4, // 北 FIGH...
摘要: virtual void registerWithTouchDispatcher(void); virtual bool ccTouchBegan(CCTouch *pTouch,CCEvent *pEvent); virtual void ccTouchMoved(CCTouch *pTouch,CCEvent *pEvent); virtual void ...
摘要: 该类已经把tableview封装好,可以把它当做一个精灵来用,这样做的好处是,当一个界面同时需要多个tableview的时候就可以很好的解决这个问题,而且模块也更清晰。//-----------------------------------------------------------------//@file gameui/Card/CardSlip.h//@date //@desc 我的卡组滑动界面//@action 我的卡组系统 //------------------------------------------...
摘要: strPath = g_ImgPath + &方正卡通简体.ttf&; m_pLebGold = CCLabelTTF::create(&&, strPath.c_str(), 30); CC_ERROR(m_pLebGold, &[CGameMainUI::onEnterTransitionDidFinish] m_pLebGold 为空&) m_pLebGold-&setPosition(ccp(60, 70)); m_pLebGold-&setAnchorPoint(CCPointZero); th
摘要: 1.假设文本框所在的父控件所能容纳的最大字体号为28,那么将字体设置为28,在适当缩放,这样字体就会比较清晰,否则真机测试的时候会很模糊不清晰。2.凡是要写在代码中的,都要将交互项选中。
摘要: #ifndef __TABLEVIEWTESTSCENE_H__#define __TABLEVIEWTESTSCENE_H__#include &cocos2d.h&#include &cocos-ext.h&void runTableViewTest();class TableViewTestLayer : public cocos2d::CCLayer, public cocos2d::extension::CCTableViewDataSource, public cocos2d::extension::CCTableViewDelegate{p
摘要: #include &../CCControlScene.h&class CCControlSliderTest : public CCControlScene{public: CCControlSliderTest(); virtual ~CCControlSliderTest(); bool init(); void valueChanged(CCObject *sender, CCControlEvent controlEvent);protected: CCLabelTTF* m_pDisplayValueL CONTROL_SCENE_CR...
摘要: #ifndef __CCCONTROLSCENE_H__#define __CCCONTROLSCENE_H__#include &cocos2d.h&#include &cocos-ext.h&USING_NS_CC;USING_NS_CC_EXT;//创建层的同时赋值标题#define CONTROL_SCENE_CREATE_FUNC(controlScene) \public: \static CCScene* sceneWithTitle(const char * title) \{ \ CCScene* pScene = CCScene::c
摘要: //类的定义#ifndef __NOTIFICATIONCENTERTEST_H__#define __NOTIFICATIONCENTERTEST_H__#include &cocos2d.h&class NotificationCenterTest : public cocos2d::CCLayer{public: NotificationCenterTest(); void toExtensionsMainLayer(cocos2d::CCObject* sender); void toggleSwitch(cocos2d::CCObject *sender); ..
摘要: const std::string testsName[MAX_COUNT] = { &Bug-350&, &Bug-422&, &Bug-458&, &Bug-624&, &Bug-886&, &Bug-899&, &Bug-914&, &Bug-1159&, &Bug-1174&};void ExtensionsMainLayer::onEnter(){ CCLayer::onEnter(); CCSize s
摘要: 引擎提供了CCGLProgram类来处理着色器相关操作,对当前绘图程序进行了封装,其中使用频率最高的应该是获取着色器程序的接口:constGLuintgetProgram();该接口返回了当前着色器程序的标识符。后面将会看到,在操作OpenGL的时候,我们常常需要针对不同的着色器程序作设置。注意,这里返回的是一个无符号整型的标识符,而不是一个指针或结构引用,这是OpenGL接口的一个风格。对象(纹理、着色器程序或其他非标准类型)都是使用整型标识符来表示的。CCGLProgram提供了两个函数导入着色器程序,支持直接从内存的字符串流载入或是从文件中读取。这两个函数的第一个参数均指定了顶点着色器,
摘要: #ifndef __MUTITOUCHTEST_H__#define __MUTITOUCHTEST_H__#include &../testBasic.h&class MutiTouchTestLayer : public CCLayer{public: bool init(); virtual void registerWithTouchDispatcher(void); virtual void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); virtual void ccTo..
摘要: #ifndef __CCDICTIONARY_H__#define __CCDICTIONARY_H__//需要哈希表的支持#include &support/data_support/uthash.h&#include &CCObject.h&#include &CCArray.h&#include &CCString.h&//Cocos2d命名空间NS_CC_BEGIN//声明一下CCDictionary类,因为CCDictElement要用到CCDictionary指针。class CCD
摘要: CCSprite* pSprite = CCSprite::spriteWithFile(&grossini.png&);pSprite-&setPosition(ccp(CCDirector::sharedDirector()-&getWinSize().width / 2, CCDirector::sharedDirector()-&getWinSize().height / 2));this-&addChild(pSprite,1,1001);pSprite-&runAction(CCOrbitCamera::create(0.5f, 2
摘要: CCSize s = CCDirector::sharedDirector()-&getWinSize(); CCNode* explosion = CCParticleSun::create(); ((CCParticleSun*)explosion)-&setTexture(CCTextureCache::sharedTextureCache()-&addImage(&fire.png&)); explosion-&setPosition( ccp(s.width/2, s.height/2) ); addChild(...
摘要: Test6::Test6(){ CCSprite* sp1 = CCSprite::create(s_pPathSister1); CCSprite* sp11 = CCSprite::create(s_pPathSister1); CCSprite* sp2 = CCSprite::create(s_pPathSister2); CCSprite* sp21 = CCSprite::create(s_pPathSister2); sp1-&setPosition(ccp(100,160)); sp2-&setPosition(ccp(380...
摘要: Test5::Test5(){ CCSprite* sp1 = CCSprite::create(s_pPathSister1); CCSprite* sp2 = CCSprite::create(s_pPathSister2); sp1-&setPosition(ccp(100,160)); sp2-&setPosition(ccp(380,160)); CCRotateBy* rot = CCRotateBy::create(2, 360); CCActionInterval* rot_back = rot-&reverse(); CCAc...
摘要: Test4::Test4(){ CCSprite *sp1 = CCSprite::create(s_pPathSister1); CCSprite *sp2 = CCSprite::create(s_pPathSister2); sp1-&setPosition( ccp(100,160) ); sp2-&setPosition( ccp(380,160) ); addChild(sp1, 0, 2); addChild(sp2, 0, 3); //在第二秒的时候执行delay2函数 schedule( schedule_sel...
摘要: void Test2::onEnter(){ TestCocosNodeDemo::onEnter(); CCSize s = CCDirector::sharedDirector()-&getWinSize(); CCSprite *sp1 = CCSprite::create(s_pPathSister1); CCSprite *sp2 = CCSprite::create(s_pPathSister2); CCSprite *sp3 = CCSprite::create(s_pPathSister1); CCSprite *sp4 = CCSp...
摘要: #ifndef _DRAW_PRIMITIVES_TEST_H_#define _DRAW_PRIMITIVES_TEST_H_////----#include &cocos2d.h&#include &../testBasic.h&class DrawPrimitivesTest : public CCLayer{public: DrawPrimitivesTest(); virtual void draw();//必须重写这个函数,画图要在这函数中画};class DrawPrimitivesTestScene : public TestScene{
摘要: void MotionStreakTest1::onEnter(){ MotionStreakTest::onEnter(); CCSize s = CCDirector::sharedDirector()-&getWinSize(); // the root object just rotates around m_root = CCSprite::create(s_pPathR1); addChild(m_root, 1); m_root-&setPosition(ccp(s.width/2, s.height/2)); // the ta...
摘要: //创建类的对象,并返回相应类的指针/** * define a create function for a specific type, such as CCLayer * @__TYPE__ class type to add create(), such as CCLayer */#define CREATE_FUNC(__TYPE__) \static __TYPE__* create() \{ \ __TYPE__ *pRet = new __TYPE__(); \ if (pRet && pRet-&init()) \ { \ pRet-&autor..
摘要: 关于scheduleUpdate看这篇即可/blog/archives/56接下来是示例代码: CCSize size = CCDirector::sharedDirector()-&getWinSize(); //创建二个精灵,一绿一红 CCSprite *psSprite1 = CCSprite::create(&green.png&); CCSprite *psSprite2 = CCSprite::create(&red.png&); //利用精灵创建进度条,并设置一些属...
摘要: pSprite-&setAnchorPoint(CCPoint(0,0)); pSprite-&setPosition(CCPoint(300,700)); CCFiniteTimeAction* pAcion = CCEaseElasticOut::actionWithAction( CCMoveTo::create(1.0f,CCPoint(300,300)),0.6f);//通过第二个参数来调整振幅,或者速度,值越大越慢振幅越小 pSprite-&runAction( CCRepeatForever::create( ...
摘要: 关于ccTouchesEnded看这个博客即可/archive//cocos2d-x-touch.htmlclass ClickAndMoveTestScene : public TestScene{public: virtual void runThisTest();};class MainLayer : public CCLayer{public: MainLayer(); virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);};...
摘要: CCLayer中的setTouchEnabled(true)会开启多点触摸。 如果使用CCDirector::sharedDirector()-&getTouchDispatcher()-&addTargetedDelegate(this,0,true); 只会开启一个点的触摸。 当HelloWorld::ccTouchBegan返回为false的时候,TouchDispatcher将会相应下一个优先级的触摸代理。 bool HelloWorld::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { } ,如
摘要: CCActionInterval* createEffect(int nIndex, float t){ CCDirector::sharedDirector()-&setDepthTest(false); switch(nIndex) { case 0: return Shaky3DDemo::create(t); case 1: return Waves3DDemo::create(t); case 2: return FlipX3DDemo::create(t); case 3: return FlipY3DDem...
摘要: Test中使用的特效如下首先,使用ccg(x,y)建grid,一个Grid属性就好像一个矩阵,是一个网络的线,组成一系列的方块和矩阵。一个(16,12)大小的grid将会运行的非常快,但是并不会看起来非常的好。(32,24)的将会看起来非常棒,但是在iphone1代中,运行起来不会太快。任何一个屏幕的Frame都会改称成一个Texture(FBO),这个纹理会转换城一个顶点array,这个顶点坐标array是通过grid的效果转换来的。最后,这个顶点数组被显示到屏幕上。CCShaky3D::actionWithRange(5,true,ccg(15,10),t);//第一个参数是扭曲范围,第二
摘要: 在cocos2d中同样提供了很多表现图片和精灵的方式,上一篇当中提到的切换场景的方式之一是顺或逆时针切入的方法,在图片上也可以使用,test里有一个例子介绍CCProgressTimer可以实现一些图片的特效效果,这样的效果可以在载入的时候作为载入动画步骤1.定义CCProgressTo,通过actionWithDuration函数,第一个参数是时间是一个CCTime对象,第二个参数是结果显示图片的百分比,如例子中一个100%,一个50%步骤2 定义CCProgressTimer,通过progressWithFile,参数是图片路径步骤3 调用setType设置类型,kCCProgressTi
摘要: CCTransitionScene* createTransition(int nIndex, float t, CCScene* s){ // fix bug #486, without setDepthTest(false), FlipX,Y will flickers CCDirector::sharedDirector()-&setDepthTest(false); switch(nIndex) { case 0: return CCTransitionJumpZoom::create(t, s); case 1: return CCTransiti...
摘要: //程序开始后延时2秒才开始addSprite函数scheduleOnce(schedule_selector(Issue1305::addSprite), 2);转到定义:void CCNode::scheduleOnce(SEL_SCHEDULE selector, float delay){ this-&schedule(selector, 0.0f, 0, delay);}void Issue1305::addSprite(float dt){ m_pSpriteTmp-&setPosition(ccp(250,250)); addChild(m_pSpriteTmp...
摘要: CCSet *m_pPausedT类的成员变量void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)void PauseResumeActions::onEnter(){ ActionsDemo::onEnter(); this-&centerSprites(2); m_tamara-&runAction(CCRepeatForever::create(CCRotateBy::create(3, 360))); ...
摘要: 在class HelloWorld : public cocos2d::CCLayer中添加void draw();实现:void HelloWorld::draw(){ CCSize s = CCDirector::sharedDirector()-&getWinSize(); CCPointArray *array = CCPointArray::create(20); array-&addControlPoint(ccp(0, 0)); array-&addControlPoint(ccp(80, 80)); array-&addControlPoint(c...
摘要: CCCatmullRomBy:把某一对象以Catmull-Rom curve曲线移动一段距离 CCPointArray *array = CCPointArray::create(20); array-&addControlPoint(ccp(0, 0)); array-&addControlPoint(ccp(80, 80)); array-&addControlPoint(ccp(s.width - 80, 80)); array-&addControlPoint(ccp(s.width - 80, s.height - 80)); array-...
摘要: class CC_DLL CCCallFunc : public CCActionInstant //void Issue1305_2::onEnter(){ ActionsDemo::onEnter(); centerSprites(0); CCSprite *spr = CCSprite::create(&Images/grossini.png&); spr-&setPosition(ccp(200,200)); addChild(spr); CCMoveBy* act1 = CCMoveBy::create(2 ,ccp(0, 100)); //...
摘要: 改变动作执行对象CCTargetedAction通常默认的动作执行对象是调用runAction的对象,而CCTargetedAction可以改变动作执行对象。CCTargetedAction* t = CCTargetedAction::create(sprite2, moveto);sprite-&runAction(CCSequence::create(moveto, t, moveto, NULL));sprite先moveto,然后sprite2执行moveto,最后sprite执行moveto。void ActionTargeted::onEnter(){ ActionsDem
摘要: CCActionInterval* move1 = CCMoveBy::create(1, ccp(250,0)); CCActionInterval* move2 = CCMoveBy::create(1, ccp(0,50)); CCToggleVisibility* tog1 = new CCToggleVisibility(); CCToggleVisibility* tog2 = new CCToggleVisibility(); tog1-&autorelease(); tog2-&autorelease(); //目前的理解是夹...
摘要: 有限次执行一组动作和无限次执行一组动作void ActionRotateJerk::onEnter(){ ActionsDemo::onEnter(); centerSprites(2); CCFiniteTimeAction* seq = CCSequence::create( CCRotateTo::create(0.5f, -20), CCRotateTo::create(0.5f, 20), NULL); CCActionInterval* rep1 = CCRepeat::create(seq, 10); C...
摘要: voidremoveFromParentAndCleanup(bool cleanup)//删除父节点中的当前节点并清除动作及回调函数void ActionCallFuncND::onEnter(){ ActionsDemo::onEnter(); centerSprites(1); CCFiniteTimeAction* action = CCSequence::create(CCMoveBy::create(2.0f, ccp(200,0)), CCCallFuncND::create(this, callfuncND_selector(ActionCall...
摘要: CCFollow动作,可以让一个节点跟随另一个节点做位移。CCFollow经常用来设置layer跟随sprite,可以实现类似摄像机跟拍的效果效果是精灵在地图上移动,地图也会跟着移动,但是精灵仍然是在整个界面的中心位置CCSize s = CCDirector::sharedDirector()-&getWinSize(); pSprite-&setPosition(ccp(-200, s.height / 2)); CCActionInterval* move = CCMoveBy::create(2, ccp(s.width * 3, 0)); ...
摘要: Cocos2d-x提供了一中根据球面坐标轨迹旋转的方式CCOrbitCameraCC_DEPRECATED_ATTRIBUTE static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);参数分别为旋转的时间,起始半径,半径差,起始z角,旋转z角差,起始x角,旋转x角差CCActionInterval* orbit1 = CCOrbitCamera::cre.
摘要: void ActionDelayTime::onEnter(){ ActionsDemo::onEnter(); alignSpritesLeft(1); CCActionInterval* move = CCMoveBy::create(1, ccp(150,0)); CCFiniteTimeAction* action = CCSequence::create( move, CCDelayTime::create(2), move, NULL); m_grossini-&runAction(action);}连续动作的反向动作void ActionReve...
摘要: CCSize boxSize = CCSizeMake(100.0f, 100.0f); CCLayerColor *box = CCLayerColor::create(ccc4(255, 255, 0, 255)); box-&setAnchorPoint(ccp(0, 0)); box-&setPosition(ccp(190, 110)); box-&setContentSize(boxSize);CCAnimation* animation = CCAnimation::create(); for( int i=1;iaddSpriteFrameWith...
摘要: 通过CCAnimation实例获取CCSpriteFrame,会出现类型转换问题。我们在创建一个animation的时候,经常遵循下面的步骤:1)create 一个CCArray对象A。2)通过A-&addObject()添加CCSpriteFrame对象3)通过CCAnimation::createWithSpriteFrames(A, 0.2f)常见一个CCAnimation对象B。可以通过B-&getFrames()获得一个CCArray*的指针A’,然后通过A’-&ObjectAtIndex(0)获得第一个CCObject*类型的对象,称之为C。从表面上看,A’和A应
摘要: CCLayer,CCSceneCCLayer类对应cocos2d-x引擎里的布景。每个游戏场景中都可以有很多层,每一层负责各自的任务,例如专门负责显示背景、专门负责显示道具和专门负责显示人物角色等。在每个层上面可以放置不同的元素,包括文本、精灵和菜单等。CCScene类对应cocos2d-x引擎里的场景,CCScene中存放的是需要渲染的布景、人物角色、和菜单,它可以作为一个整体,一起渲染,一起销毁,一起被场景切换使用。CCActionCCAction这个类是动作的基类,有点需要注意的就是,我们不光可以通过CCSpawn让动画一起播放,我们在调用runAction的时候本身就是一种一起播放(即
摘要: cocos2d-x定义了很多宏定义,帮我们提高开发效率,下面看下CC_PROPERTY,CC_PROPERTY定义CC_PROPERTY的声明在CCPlatformMacros.h中,结构如下#define CC_PROPERTY ( varType, varName, funName) varType : 变量类型.varName :变量名称funName : &get + funName&是变量的getter. &set + funName&是变量的setter.成员函数和成员变量有protected: varType varN...
摘要: CCCallFunc CCCallFuncN CCCallFuncND都用来创建带有回调函数的动作,区别主要在于回调函数是否带有参数CCCallFunc是执行对应的回调函数,其中回调函数不可带参数。一般使用静态成员函数create创建实例,create声明如下:static CCCallFunc* create ( CCObject * pSelectorTarget,SEL_CallFunc selector)回调函数通过execute方法执行,CCCallFunc中的execute的实现如下:void CCCallFunc::execute() { if ...
摘要: RemoveSelf :消失CCFiniteTimeAction* action = CCSequence::create( CCMoveBy::create( 2, ccp(240,0)), CCRotateBy::create( 2, 540), CCScaleTo::create(1,0.1f), CCRemoveSelf::create(), NULL);CCRemoveSelf::create这个的效果大家看到了就是让精灵越来越小,直到消失。Spawn:同时执行动作CCAction* action = CCSpawn::create( ...
摘要: //CCAnimation是封装动画功能的类,它可以看作是由若干个_CCSpriteFrame对象组成的序列,精灵按照顺序切换它们,就形成了动画。CCAnimation也有内存池, //此处的animationName就是key,内存池通过它找到CCAnimation对象,再通过索引frameIndex找到动画序列中的某一帧,将该帧设为精灵的当前显示帧。 CCAnimation* animation = CCAnimation::create(); for( int i=1;iaddSpriteFrameWithFileName(szName); } // sh...
摘要: #ifndef SHOP_H#define SHOP_H#include &XWidget.h&#include &GameConfig.h&class CXSclass CXIclass CXBclass CXTclass CXC#define SHOP_NOCHECKED_INIT_ID 1060#define SHOP_CHECKED_INIT_ID 1050#define SHOP_GOODS_NUM 6#define SHOP_GOODS_BTN_INIT_ID 1070#defin...
摘要: 一,IOS与图片内存在IOS上,图片会被自动缩放到2的N次方大小。比如一张的图片,占用的内存与一张的图片是一致的。图片占用内存大小的计算的公式是;长*宽*4。这样一张512*512 占用的内存就是 512*512*4 = 1M。其他尺寸以此类推。(ps:IOS上支持的最大尺寸为)。二,cocos2d-x 的图片缓存Cocos2d-x 在构造一个精灵的时候会使用spriteWithFile或者spriteWithSpriteFrameName等 无论用哪种方式,cocos2d-x都会将这张图片加载到缓存中。如果是第一次加载这个图片,那就会先将
摘要: #ifndef __GAMECONFIG_H__#define __GAMECONFIG_H__#include &GameFrameHead.h&#include &GameParam.h&//生物配置struct BiontInfo{ int nId; int nT //生物类型 CCRect rA //生物活动区域 int nB //体积 int nW //重量 string ...
摘要: #ifndef __CONFIG_H__#define __CONFIG_H__#include &GameFrameHead.h&//图片信息struct ImageInfo{ int nId; //ID标识 string strK //key标识 string strF //文件路径};//资源信息struct ResourceInfo{ };//ui//控件信息struct CtrlInfo{ int nId; CCPoint tP //坐标 CCPoi...
摘要: #ifndef __EFFECTMGR_H__#define __EFFECTMGR_H__#include &GameFrameHead.h&namespace cocos2d{ class CCFiniteTimeA}class GAMEFRAME_API CEffectMgr{public: enum ActionType { _Act_Sequence = 0, //顺序执行 _Act_Spawn = 1, //同时执行 }; enum Action { _CCMoveTo =...
摘要: #ifndef __TRANSITIONSCENE_H__#define __TRANSITIONSCENE_H__#include &GameFrameHead.h&class CGameSclass GAMEFRAME_API CSplashScene : public CCScene{public: enum TargetScenes { TargetSceneINVALID = 0, TargetSceneFirstScene = 1, TargetSceneOtherScene = 2, ...
摘要: #ifndef __GAMEMAIN_SCENE_H__#define __GAMEMAIN_SCENE_H__#include &cocos2d.h&#include &Box2D/Box2D.h&#include &SimpleAudioEngine.h&#include &CocoHead.h&#include &GameScene.h&class CCLclass CGameMainScene : public CGameScene{public: enum ResourceI
摘要: #ifndef __LOADSCENE_H__#define __LOADSCENE_H__#include &GameFrameHead.h&class CGameSclass CLoadScene : public cocos2d::CCLayer{public: enum PmgressbarId { _PmgressbarDialog = 100, _PmgressbarPic = 1001, };public: CLoadScene(); virtual ~CLoadScene(void); ...
摘要: #ifndef __CONTROLLAYER_H__#define __CONTROLLAYER_H__#include &XWidget.h&class CMapDclass CXTclass CTowerDclass CControlLayer : public CXWidget{public: enum ControlLayerId { _IDD_ControLyaer = 102, };public: CControlLayer(); ~CControlLayer(); virtual bool ini...
摘要: /************************************************************************//* 预先加载一些生物以备将来使用 *//* 专门用来缓存生物用的 *//* 使用时通过生物ID或者名字来查找对象 *//************************************...
摘要: #ifndef __HERO_H__#define __HERO_H__#include &GameFrameHead.h&#include &GameParam.h&class CHero{public: struct Attribute { //成就 //总 //long long llTotalM //long long llTotalS long long llTotalC long long llTotalPerfectToC ...
摘要: #include &WidgetMgr.h&#include &XWidget.h&#include &Config.h&#include &XButton.h&#include &XImage.h&#include &XStatic.h&#include &XNoTouch.h&#include &XSroll.h&CWidgetMgr* CWidgetMgr::g_pUiMgr = NULL;CWidgetMgr::CWidgetM
摘要: /************************************************************************///管理部件//部件自动根据Z顺序调整消息的优先级 /************************************************************************/#ifndef __WIDGETMGR_H__#define __WIDGETMGR_H__#include &GameFrameHead.h&class CXWindow...
摘要: #include &XAnimation.h&CXAnimation::CXAnimation(void){ m_strName = &&; m_nFrameCount = 0; m_fInterval = 0.0f;}CXAnimation::~CXAnimation(){}CXAnimation* CXAnimation::create( const char* psName, int nBegan, int nCount, float delayPerUnit /*= 1.0*/ ){ CXAnimation* pAnimation = new C
摘要: /****************************************************************************使用一个CCAnimation对象可以CCSprite对象上执行动画。 CCAnimation对象包含CCSpriteFrame对象,与帧之间可能出现的延误。可以使用CCAnimate的方法 播放CCAnimation对象。*****************************************************************************/#ifndef __CXAnimation_H__#define
摘要: #ifndef __XCOMMON_H__#define __XCOMMON_H__/************************************************************************///XCommon.h 是通用类,提供一些功能//1.字符串截断//2.坐标转换//3.文字乱码处理// /************************************************************************/#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)#include &qu
摘要: #include &XSprite.h&CXSprite::CXSprite(void){ m_strPic.clear();}CXSprite::~CXSprite(){}/**********************************函数名称:createSprite*函数功能:创建精灵*函数参数:const char* psFile--创建精灵用的图片 int nFrameIndex--(-1--普通图片 0-2--按钮图片帧(按钮统一为3帧))*函数返回值:创建的精灵指针*备注:分两种情况来创建1.第一种:只是简单的通过图片来创建2.第二种:通过纹理来创...
摘要: #ifndef __XSprite_H__#define __XSprite_H__#include &CocoHead.h&#define BTN_FRAME_AMOUNT 3class ENGINE_API CXSprite : public CCSprite{public: /* 按钮的图片分割成几张 那个分割后每张的索引值 */ enum BTN_FRAME_INDEX { BTN_FRAME_0 = 0, BTN_FRAME_1 = 1, BTN_FRAME_2 = 2, BTN_FRAME_3...
摘要: #include &SectsInfomation.h&#include &WidgetMgr.h&#include &XButton.h&#include &XSroll.h&#include &Config.h&#include &XCommon.h&#include &XStatic.h&#include &XImage.h&#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)#include &q
摘要: #ifndef SECTSINFOMATION_H#define SECTSINFOMATION_H#include &XWidget.h&#include &XImage.h&#include &XStatic.h&#include class CXBclass CSectsInfomation : public CXWidget{public: CSectsInfomation(void); ~CSectsInfomation(void);public: enum CSectsInfomationId { _IDD_C
摘要: /************************************************************************///屏蔽消息面板 //优先级默认为 TP_BOTTOM = 1, // /************************************************************************/#ifndef __XNOTOUCH_H__#define __XNOTOUCH_H__#include &XWindow.h&class ENGINE_API CXNoTouch : public CXWind
摘要: #ifndef __XSROLL_H__#define __XSROLL_H__#include &CocoHead.h&#include &XWindow.h&class ENGINE_API CXSroll : public CXWindow{public: enum XSrollType { _SrollDirectionVertical = 0, //垂直 _SrollDirectionHorizontal = 1, //水平 _SrollVerticalTable ...
摘要: 1 /************************************* 2 *函数名称:visit 3 *函数功能:获取游戏设计的分辨率与真实设备的比例,并根据值来剪切显示区域 4 *函数参数:void 5 *函数返回值:void 6 *笔记: 7 1.glEnable用于开启opengl相应的功能 8 2.GL_SCISSOR_TEST根据函数glScissor设置,启用图形剪切 9 3.glScissor10 http://blog.csdn.net/augusdi/article/details/ ****************************...
摘要: //编码转换 //#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) // string title = &成绩&; // GBK2UTF8(title,&gb2312&,&utf-8&); //#endif static int GBK2UTF8(std::string & gbkStr, const char* toCode, const char* fromCode) { iconv_t iconvH; iconvH = iconv_open(fromCo...
摘要: /****************************************************************************Copyright (c) 2010 cocos2d-x.orghttp://www.cocos2d-x.orgPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the &Software&), to dealin t
摘要: //转换坐标 //锚点为(x,x)是的坐标转换成锚点为(0,0)的坐标 //例如:把锚点(0.5,0.5)坐标(0,0)转换成 //锚点(0.5,0.5)坐标(0 - pNode.getContentSize.width * 0.5,0 - pNode.getContentSize.Height * 0.5) static void anchorToLocalPos(CCNode* pNode) { pNode-&setPositionX(pNode-&getPositionX() + pNode-&getContentSize().width * ...
摘要: MapInfo* CGameConfig::getMapInfoById( int nId ){ for (map::iterator it = m_mapMapInfo.begin(); it != m_mapMapInfo.end(); it++) { if (nId == it-&first) { return &(it-&second); } } CCLog(&error: CGameConfig::getMapInfoById&); return NULL;}
摘要: &100,100;500,500;300,300;150,150;30,30&static void split(const string& src, const string& separator, vector& dest) { string str = string::size_type start = 0, do { index = str.find_first_of(separator,start); if...
摘要: // libxmlTest.cpp : 定义控制台应用程序的入口点。//#include &stdafx.h&#include #include #include #include int _tmain(int argc, _TCHAR* argv[]){ //定义文档和节点指针 xmlDocPtr doc = xmlNewDoc(BAD_CAST &1.0&); xmlNodePtr root_node = xmlNewNode(NULL,BAD_CAST&root&); //设置根节点 xmlDocSetRootElement(d
摘要: 打开然后将图片拖入点击回到项目中,添加现有项,得到CCSpriteFrameCache::sharedSpriteFrameCache()-&addSpriteFramesWithFile(&spriteframe.plist&); CCSpriteFrame* pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()-&spriteFrameByName(&12.png&); CCSprite *pSprite = CCSprite::spriteWithSpriteFrame(pFrame
摘要: #ifndef HROCKER_H#define HROCKER_H#include &cocos2d.h&using namespace cocos2d;//用于标识摇杆与摇杆的背景typedef enum{ tag_rocker, tag_rockerBG,}tagForHRclass HRocker:public CCLayer{public: HRocker(void); ~HRocker(void); //创建摇杆(摇杆的操作题图片资源名,摇杆背景图片资源名,起始坐标) static HRocker* createHRocker...
摘要: //自定义粒子 CCParticleSystem* myParticle = CCParticleSystemQuad::create(&Flower.plist&); addChild(myParticle);
摘要: CCParticleSystem* particleSystemFree = CCParticleSun::create(); //设置贴图 particleSystemFree-&setTexture(CCTextureCache::sharedTextureCache()-&addImage(&fire.png&)); //设置自动释放 particleSystemFree-&setAutoRemoveOnFinish(true); //设置类型移动类型kCCPositionTypeFree-----随着layer的移...
摘要: 1 //爆炸粒子效果 2 CCParticleSystem* particleSystem = CCParticleExplosion::create(); 3 particleSystem-&setTexture(CCTextureCache::sharedTextureCache()-&addImage(&stars.png&)); 4 this-&addChild(particleSystem); 5 6 //火焰粒子效果 7 CCParticleSystem* particleSystem = CCPa...
摘要: 1 #ifndef BASE_DATA 2 #include 3 4 class BaseData 5 { 6 public: 7 BaseData(void); 8 ~BaseData(void); 9 10 std::string saveData(char const* bytes_to_encode,unsigned int in_len);11 std::string parseData(std::string const& encoded_string);12 13 };14 15 #endif 1 #include &BaseData.h...}

我要回帖

更多关于 cocos2d x 获取时间 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信