コード例 #1
0
ファイル: TankState.cpp プロジェクト: yw920/tank
bool TankState::beAttacked()
{
	
	Armature* armature = Armature::create("explodeAnimation");
	// 设置当前运行动画的索引,一个“工程”可以建立多个动画
	armature->getAnimation()->playWithIndex(0);
	armature->getAnimation()->setMovementEventCallFunc([](Armature *armature, MovementEventType movementType, const std::string& movementID){
		armature->removeFromParent();
	});
	// 设置位置信息
	armature->setPosition(_tank->getPosition());
	// 添加到容器,当前运行的场景之中
	_tank->getParent()->addChild(armature);
	_tank->setState(new TankStateRebirth(this));
	
	return false;
}
コード例 #2
0
 void BarrelBottom::playEffect()
 {
     using cocostudio::ArmatureDataManager;
     using cocostudio::Armature;
     if (effect_flag_)
     {
         effect_flag_ = false;
         Armature* armature = Armature::create(BARREL_BOTTOM_EFFECT_NAME);
         armature->getAnimation()->playWithIndex(0, SPECIAL_BUBBLE_EFFECT_DURATION, false);
         armature->getAnimation()->setMovementEventCallFunc([=](Armature* armature, cocostudio::MovementEventType type, const std::string&) {
             if (type == cocostudio::COMPLETE)
             {
                 armature->removeFromParent();
                 effect_flag_ = true;
             }
         });
         //armature->setPositionY(BARREL_BOTTOM_EFFECT_POSITION_Y);
         //armature->setPosition(-20, -20);
         this->addChild(armature);
     }
 }