(7) cocos2dx 自定义动画 和 使用cocostudio动画

// getContentSize函数来获得节点原始的大小。只是逻辑尺寸,不是像素,若是DesignResolutionSize跟屏幕尺寸一样大,则getVisibleSize便是getWinSize。

// getContentSizeInPixels获得的是像素点大小

// 像素点和逻辑点关系:逻辑点大小 = 像素大小/contentScaleFactor.

// getVisibleOrigin:获得可视区域的出发点坐标,在处理相对位置时,确保节点在不同分辨率下的位置一致。

auto winSize = Director::getInstance()->getVisibleSize();

// hero

auto hero = Sprite::create(bird_hero);

hero->setPosition(winSize.width / 3,winSize.height*0.8);

hero->setVisible(false);

hero->setTag(TAG_HERO);

this->addChild(hero,1);

Animation* an = Animation::create();

an->addSpriteFrameWithFileName(bird_hero);

an->addSpriteFrameWithFileName(bird_hero2);

an->addSpriteFrameWithFileName(bird_hero3);

an->setDelayPerUnit(0.5f / 3.0f); //必须设置否则不会动态播放

an->setLoops(-1); //重复次数 (-1:无限循环)

Animate* anim = Animate::create(an);

hero->runAction(anim);


cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("tauren0.png","tauren0.plist","tauren.ExportJson");

armature = cocostudio::Armature::create("tauren");

armature->getAnimation()->playByIndex(0);

armature->setScale(1.0f);

armature->setPosition(Vec2(x.asInt()+50,y.asInt()));

this->addChild(armature);

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...