コード例 #1
0
ファイル: GameObject.cpp プロジェクト: VajraFramework/Vajra
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
0
ファイル: CCBatchNode.cpp プロジェクト: DominicD/Hyperdrive
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
0
ファイル: ArmatureScene.cpp プロジェクト: songmiao/WagonWar
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
0
ファイル: Mainui.cpp プロジェクト: cocositachi/Tui-x
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
0
ファイル: HelloWorldScene.cpp プロジェクト: tredyfa/test
// 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
0
	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
0
ファイル: CCTween.cpp プロジェクト: bonlai/3kaigame
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
0
ファイル: CCBatchNode.cpp プロジェクト: CryQ/coclua
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
0
ファイル: CCBatchNode.cpp プロジェクト: leanlyne/ShootColorX
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
0
void HelloWorld::update(float dt)
{
	CCObject *_object = NULL;
	CCARRAY_FOREACH(armatures, _object)
	{
		Armature *armature = (Armature*)_object;
		armature->update(dt);
	}
コード例 #11
0
	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
0
ファイル: ArmatureScene.cpp プロジェクト: songmiao/WagonWar
Armature * TestArmatureNesting2::createMount(const char *name, Vec2 position)
{
    Armature *armature = Armature::create(name);
    armature->getAnimation()->playWithIndex(0);
    armature->setPosition(position);
    addChild(armature);

    return armature;
}
コード例 #13
0
ファイル: TuiManager.cpp プロジェクト: zh0ub1n/Tui-x
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;
}
コード例 #14
0
	Object* Slot::getDisplay() {
		Object* display = displayList[_displayIndex];
		if(checkIfClass<Armature>(display)) 
		{
			Armature* d = (Armature*) display;
			return (Object*)d->getDisplay();
		}
		return display;
	}
コード例 #15
0
void DisplayFactory::updateArmatureDisplay(Bone *bone, Node *display, float dt)
{
    Armature *armature = (Armature *)display;
    if(armature)
    {
        armature->sortAllChildren();
        armature->update(dt);
    }
}
コード例 #16
0
// 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;
}
コード例 #17
0
ファイル: CCBatchNode.cpp プロジェクト: DominicD/Hyperdrive
void BatchNode::removeChild(Node* child, bool cleanup)
{
    Armature *armature = dynamic_cast<Armature *>(child);
    if (armature != nullptr)
    {
        armature->setBatchNode(nullptr);
    }

    Node::removeChild(child, cleanup);
}
コード例 #18
0
ファイル: CCDisplayFactory.cpp プロジェクト: Ratel13/HXGame
void DisplayFactory::updateArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay, float dt, bool dirty)
{
    CS_RETURN_IF(!dirty);

    Armature *armature = bone->getChildArmature();
    if(armature)
    {
        armature->sortAllChildren();
        armature->update(dt);
    }
}
コード例 #19
0
ファイル: CCArmature.cpp プロジェクト: 0x0c/cocos2d-x
Armature *Armature::create(const char *name, Bone *parentBone)
{
    Armature *armature = new Armature();
    if (armature && armature->init(name, parentBone))
    {
        armature->autorelease();
        return armature;
    }
    CC_SAFE_DELETE(armature);
    return NULL;
}
コード例 #20
0
ファイル: CCArmature.cpp プロジェクト: 0x0c/cocos2d-x
Armature *Armature::create()
{
    Armature *armature = new Armature();
    if (armature && armature->init())
    {
        armature->autorelease();
        return armature;
    }
    CC_SAFE_DELETE(armature);
    return NULL;
}
コード例 #21
0
void MultiPriceMatch::PlayAnimation(float dt)
{
	Armature *armature = dynamic_cast<Armature *>(_SORT_UINode->getChildByTag(888));
	armature->getAnimation()->playWithIndex(0, -1, 0);//from the first frame, no loop
	armature->getAnimation()->setSpeedScale(0.8);
	AppDelegate* app = (AppDelegate*)Application::getInstance();
	if (app->getBGMstatus() == BGMusic_flag::ON)
	{
		app->PlayEffect(SOUND_ANIMATION);
	}
}
コード例 #22
0
ファイル: CCArmature.cpp プロジェクト: 2276225819/Game
Armature *Armature::create(const std::string& name, Bone *parentBone)
{
    Armature *armature = new Armature();
    if (armature && armature->init(name, parentBone))
    {
        armature->autorelease();
        return armature;
    }
    CC_SAFE_DELETE(armature);
    return nullptr;
}
コード例 #23
0
Armature *Armature::create(const std::string& name)
{
    Armature *armature = new (std::nothrow) Armature();
    if (armature && armature->init(name))
    {
        armature->autorelease();
        return armature;
    }
    CC_SAFE_DELETE(armature);
    return nullptr;
}
コード例 #24
0
void CS_DISPLAY_ARMATURE_UPDATE(Bone *bone, DecorativeDisplay *decoDisplay, float dt, bool dirty)
{
	CS_RETURN_IF(!dirty);

	Armature *armature = bone->getChildArmature();
	if(armature)
	{
		armature->sortAllChildren();
	 	armature->update(dt);
	}
}
コード例 #25
0
ファイル: ArmatureScene.cpp プロジェクト: songmiao/WagonWar
void TestCSWithSkeleton::onEnter()
{
    ArmatureTestLayer::onEnter();
    Armature *armature = nullptr;
    armature = Armature::create("Cowboy");
    armature->getAnimation()->playWithIndex(0);
    armature->setScale(0.2f);

    armature->setPosition(VisibleRect::center().x, VisibleRect::center().y/*-100*/);
    addChild(armature);
}
コード例 #26
0
ファイル: TuiManager.cpp プロジェクト: Kudoo/Tui-x
Armature* TuiManager::createArmature(float tag,const char* name,const char* png,const char* plist,const char* xml,float x,float y,float rotation){
	if(m_isUseSpriteFrame){
		ArmatureDataManager::getInstance()->addSpriteFrameFromFile(plist,png,xml);
	}else{
		ArmatureDataManager::getInstance()->addArmatureFileInfo(png,plist,xml);
	}
	Armature *pArmature = Armature::create(name);
	pArmature->setPosition(Point(x,-y));
	pArmature->setRotation(rotation);
	pArmature->setTag(tag);
	return pArmature;
}
コード例 #27
0
ファイル: ArmatureScene.cpp プロジェクト: songmiao/WagonWar
void TestDragonBones20::onEnter()
{
    ArmatureTestLayer::onEnter();

    Armature *armature = nullptr;
    armature = Armature::create("Dragon");
    armature->getAnimation()->playWithIndex(1);
    armature->getAnimation()->setSpeedScale(0.4f);
    armature->setPosition(VisibleRect::center().x, VisibleRect::center().y * 0.3f);
    armature->setScale(0.6f);
    addChild(armature);
}
コード例 #28
0
ファイル: Flash.cpp プロジェクト: Jinchenyuan/shjs
Armature* CFlashControl::CreateMonster(MonsterInfomation* _pMonsterInfo)
{
	int type = _pMonsterInfo->type;
#ifdef GameTypeC
	if ( type == 8 )
		type = 5;
#endif
	Armature* pArmature = Armature::create(g_sMonsterName[type].c_str());
	pArmature->setPosition(_pMonsterInfo->x, _pMonsterInfo->y);
	m_pHeroLayer->SetMonster(pArmature);
	return pArmature;
}
コード例 #29
0
ファイル: CCBatchNode.cpp プロジェクト: DominicD/Hyperdrive
void BatchNode::addChild(cocos2d::Node *child, int zOrder, const std::string &name)
{
    Node::addChild(child, zOrder, name);
    Armature *armature = dynamic_cast<Armature *>(child);
    if (armature != nullptr)
    {
        armature->setBatchNode(this);
        if (_groupCommand == nullptr)
        {
            _groupCommand = new (std::nothrow) GroupCommand();
        }
    }
}
コード例 #30
0
cocos2d::Node* EffectComponentTest::createGameScene()
{
    Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.json");
	if (node == nullptr)
	{
		return nullptr;
	}
	_node = node;
    ComRender *render = static_cast<ComRender*>(_node->getChildByTag(10015)->getComponent("CCArmature"));
	Armature *pAr = static_cast<Armature*>(render->getNode());
	pAr->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(EffectComponentTest::animationEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
    return node;
}