本文整理汇总了C++中Armature类的典型用法代码示例。如果您正苦于以下问题:C++ Armature类的具体用法?C++ Armature怎么用?C++ Armature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Armature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void GameObject::Draw() {
if (this->visible) {
this->transform->Draw();
#if USING_RUNTIME_COMPUTED_BONE_MATRICES
// TODO [Cleanup] Cache the Armature, maybe
Armature* armature = this->GetComponent<Armature>();
if (armature != nullptr) {
armature->Bind();
}
#elif USING_BAKED_BONE_MATRICES
// TODO [Cleanup] Cache the BakedSkeletalAnimation component, maybe
BakedSkeletalAnimation* bakedSkeletalAnimation = this->GetComponent<BakedSkeletalAnimation>();
if (bakedSkeletalAnimation != nullptr) {
bakedSkeletalAnimation->Bind();
}
#endif
// TODO [Cleanup] Cache the Renderer, maybe
Renderer* renderer = this->GetComponent<Renderer>();
if (renderer != nullptr) {
renderer->Draw();
}
}
}
示例2: draw
void BatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (_children.empty())
{
return;
}
// CC_NODE_DRAW_SETUP();
bool pushed = false;
for(auto object : _children)
{
Armature *armature = dynamic_cast<Armature *>(object);
if (armature)
{
if (!pushed)
{
generateGroupCommand();
pushed = true;
}
armature->visit(renderer, transform, flags);
}
else
{
renderer->popGroup();
pushed = false;
((Node *)object)->visit(renderer, transform, flags);
}
}
}
示例3: addChild
void TestChangeZorder::onEnter()
{
ArmatureTestLayer::onEnter();
Armature *armature = nullptr;
currentTag = -1;
armature = Armature::create("Knight_f/Knight");
armature->getAnimation()->playWithIndex(0);
armature->setPosition(VisibleRect::center().x, VisibleRect::center().y - 100);
++currentTag;
armature->setScale(0.6f);
addChild(armature, currentTag, currentTag);
armature = Armature::create("Cowboy");
armature->getAnimation()->playWithIndex(0);
armature->setScale(0.24f);
armature->setPosition(VisibleRect::center().x, VisibleRect::center().y - 100);
++currentTag;
addChild(armature, currentTag, currentTag);
armature = Armature::create("Dragon");
armature->getAnimation()->playWithIndex(0);
armature->setPosition(VisibleRect::center().x , VisibleRect::center().y - 100);
++currentTag;
armature->setScale(0.6f);
addChild(armature, currentTag, currentTag);
schedule( schedule_selector(TestChangeZorder::changeZorder), 1);
currentTag = 0;
}
示例4: setAutoRemoveUnusedTexture
NS_MAIN_BEGIN
void Mainui::onLoadScene()
{
setAutoRemoveUnusedTexture(true);
TuiManager::getInstance()->parseScene(this,"panel_main",PATH_MAIN);
//注册事件
CControlView *ctlv = (CControlView*)this->getControl(PANEL_MAIN,CTLV_LEFT);
ctlv->setOnControlListener(this,ccw_control_selector(Mainui::event_ctlv_left));
CButton *pBtnOk = (CButton*)this->getControl(PANEL_MAIN,BTN_OK);
pBtnOk->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_ok));
CButton *pBtnGo = (CButton*)this->getControl(PANEL_MAIN,BTN_GO);
pBtnGo->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_go));
CButton *pShowPhone = (CButton*)this->getControl(PANEL_MAIN, BTN_SHOWPHONE);
pShowPhone->setOnClickListener(this, ccw_click_selector(Mainui::event_btn_showphone));
CToggleView *pTgvA = (CToggleView*)this->getControl(PANEL_MAIN, TGV_A);
pTgvA->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvA_check));
CToggleView *pTgvB = (CToggleView*)this->getControl(PANEL_MAIN, TGV_B);
pTgvB->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvB_check));
MovieView *pMovie = (MovieView*)this->getControl(PANEL_MAIN, MOVIE_TEST);
map<string, function<void()>> m;
m["finish"] = bind(&Mainui::event_movie_finish, this);
pMovie->setCallBack(m);
//播放骨骼动画(默认不播放)
Armature *armature = (Armature*)this->getControl(PANEL_MAIN,ARMATURE_BOSS1);
armature->getAnimation()->play("live",-1,1);
}
示例5: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
ArmatureDataManager::getInstance()->addArmatureFileInfo("zhanshi0.png" , "zhanshi0.plist" , "zhanshi.ExportJson");
Armature *armature = Armature::create("zhanshi");
armature->setPosition(Point(visibleSize.width * 0.5, visibleSize.height * 0.5));
// 播放动画
armature->getAnimation()->play("zhanshi_xingzou");
this->addChild(armature);
// add "HelloWorld" splash screen"
return true;
}
示例6: update
void Slot::update() {
DBObject::update();
if(_isDisplayOnStage)
{
Armature* child = this->getChildArmature();
if(parent->_tweenPivot)
{
float pivotX = parent->_tweenPivot->x;
float pivotY = parent->_tweenPivot->y;
if(parent)
{
glm::mat4 parentMatrix = parent->_globalTransformMatrix;
_globalTransformMatrix[3][0] += parentMatrix[0][0] * pivotX + parentMatrix[1][0] * pivotY;
_globalTransformMatrix[3][1] += parentMatrix[0][1] * pivotX + parentMatrix[1][1] * pivotY;
}
}
_displayBridge->updateTransform(this->_globalTransformMatrix, this->global);
if(child)
{
child->getDisplay()->setTransformationMatrix(this->_globalTransformMatrix);
}
}
}
示例7: arriveKeyFrame
void Tween::arriveKeyFrame(FrameData *keyFrameData)
{
if(keyFrameData)
{
DisplayManager *displayManager = _bone->getDisplayManager();
//! Change bone's display
int displayIndex = keyFrameData->displayIndex;
if (!displayManager->isForceChangeDisplay())
{
displayManager->changeDisplayWithIndex(displayIndex, false);
}
//! Update bone zorder, bone's zorder is determined by frame zorder and bone zorder
_tweenData->zOrder = keyFrameData->zOrder;
_bone->updateZOrder();
//! Update blend type
_bone->setBlendFunc(keyFrameData->blendFunc);
//! Update child armature's movement
Armature *childAramture = _bone->getChildArmature();
if(childAramture)
{
if(!keyFrameData->strMovement.empty())
{
childAramture->getAnimation()->play(keyFrameData->strMovement);
}
}
}
}
示例8: addChild
void BatchNode::addChild(Node *child, int zOrder, int tag)
{
Node::addChild(child, zOrder, tag);
Armature *armature = dynamic_cast<Armature *>(child);
if (armature != nullptr)
{
armature->setBatchNode(this);
const Dictionary *dict = armature->getBoneDic();
DictElement *element = nullptr;
CCDICT_FOREACH(dict, element)
{
Bone *bone = static_cast<Bone*>(element->getObject());
Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList();
for(auto object : *displayList)
{
DecorativeDisplay *display = static_cast<DecorativeDisplay*>(object);
if (Skin *skin = dynamic_cast<Skin*>(display->getDisplay()))
{
skin->setTextureAtlas(getTexureAtlasWithTexture(skin->getTexture()));
}
}
}
示例9: CC_NODE_DRAW_SETUP
void BatchNode::draw()
{
if (_children.empty())
{
return;
}
CC_NODE_DRAW_SETUP();
bool pushed = false;
for(auto object : _children)
{
Armature *armature = dynamic_cast<Armature *>(object);
if (armature)
{
if (!pushed)
{
generateGroupCommand();
pushed = true;
}
armature->visit();
}
else
{
Director::getInstance()->getRenderer()->popGroup();
pushed = false;
((Node *)object)->visit();
}
}
}
示例10: CCARRAY_FOREACH
void HelloWorld::update(float dt)
{
CCObject *_object = NULL;
CCARRAY_FOREACH(armatures, _object)
{
Armature *armature = (Armature*)_object;
armature->update(dt);
}
示例11: FrameEvent
void Bone::arriveAtFrame(Frame* frame, TimelineState* timelineState, AnimationState* animationState, bool isCross) {
if(frame)
{
int mixingType = animationState->getMixingTransform(name);
if(animationState->getDisplayControl() && (mixingType == 2 || mixingType == -1))
{
if(displayControlGroup != "") {
displayControlGroup == animationState->group;
} else {
if(displayControlLayer >= 0) {
displayControlLayer = animationState->getLayer();
} else {
displayControlLayer == true;
}
}
TransformFrame* transformFrame = (TransformFrame*) frame;
if(_slot)
{
int displayIndex = transformFrame->displayIndex;
if(displayIndex >= 0)
{
if(!transformFrame->zOrder && transformFrame->zOrder != _slot->_tweenZorder)
{
_slot->_tweenZorder = transformFrame->zOrder;
this->_armature->_slotsZOrderChanged = true;
}
}
_slot->changeDisplay(displayIndex);
_slot->updateVisible(transformFrame->visible);
}
}
if(frame->event != "" && this->_armature->hasEventListener("boneFrameEvent"))
{
FrameEvent* frameEvent = new FrameEvent(FrameEvent::BONE_FRAME_EVENT);
frameEvent->bone = this;
frameEvent->animationState = animationState;
frameEvent->frameLabel = frame->event;
this->_armature->dispatchEvent(frameEvent);
}
if(frame->action != "")
{
Armature* childArmature = this->getChildArmature();
if(childArmature)
{
childArmature->getAnimation()->gotoAndPlay(frame->action);
}
}
}
else
{
if(_slot)
{
_slot->changeDisplay(-1);
}
}
}
示例12: createArmature
Armature* TuiManager::createArmature(float tag,const char* name,const char* actionName, const char* png,const char* plist,const char* xml,float x,float y,float rotation){
ArmatureDataManager::getInstance()->addArmatureFileInfo(png,plist,xml);
Armature *pArmature = Armature::create(name);
if (actionName) pArmature->getAnimation()->play(actionName,0,1);
pArmature->setPosition(Vec2(x,-y));
pArmature->setRotation(rotation);
pArmature->setTag(tag);
return pArmature;
}
示例13: getDisplay
Object* Slot::getDisplay() {
Object* display = displayList[_displayIndex];
if(checkIfClass<Armature>(display))
{
Armature* d = (Armature*) display;
return (Object*)d->getDisplay();
}
return display;
}
示例14: updateArmatureDisplay
void DisplayFactory::updateArmatureDisplay(Bone *bone, Node *display, float dt)
{
Armature *armature = (Armature *)display;
if(armature)
{
armature->sortAllChildren();
armature->update(dt);
}
}
示例15: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
m_fTime = 0.0f;
m_bStart = false;
m_bDead = false;
m_fPercentage = 100.0f;
m_fSpeed = 4.0f;
m_fAttackDis = 120.0f;
m_pGameScene = NULL;
Node *pGameScene = cocostudio::SceneReader::getInstance()->createNodeWithSceneFile("FightScene.json");
m_pGameScene = pGameScene;
this->addChild(pGameScene);
ComRender *render = (ComRender*)(m_pGameScene->getChildByTag(10005)->getComponent("CCArmature"));
Armature *pArmature = (Armature*)(render->getNode());
pArmature->getAnimation()->play("run");
m_bStart = true;
LabelTTF* label = CCLabelTTF::create("End", "Marker Felt", 40);
auto itemBack = MenuItemLabel::create(label, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
itemBack->setColor(Color3B(255, 255, 255));
itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
Menu* menuBack =Menu::create(itemBack, NULL);
menuBack->setPosition( Point::ZERO );
menuBack->setZOrder(4);
this->addChild(menuBack);
// CCMenuItemFont *itemBack = CCMenuItemFont::create("End", this, menu_selector(HelloWorld::menuCloseCallback));
// itemBack->setColor(ccc3(255, 255, 255));
// itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
// CCMenu *menuBack = CCMenu::create(itemBack, NULL);
// menuBack->setPosition(CCPointZero);
// menuBack->setZOrder(4);
//
// this->addChild(menuBack);
scheduleUpdate();
return true;
}