本文整理汇总了C++中GameObject::GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ GameObject::GetComponent方法的具体用法?C++ GameObject::GetComponent怎么用?C++ GameObject::GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject::GetComponent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createClassButts
void Lobby::createClassButts(){
RenderManager* renderMan = RenderManager::getRenderManager();
GameObject* button;
int w, h;
float midHeight, offset;
float x, y;
renderMan->getWindowSize(&w, &h);
// height for the character class buttons
midHeight = h * (1 / 2.0f);
// finding the offset of the slots
offset = w * (1 / 4.0f);
// chicken button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
button = bFactory.Spawn(buttonID++, x, y, 50, 75.0f, 75.0f, 0.75f);
dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("chickensfx.ogg");
classButt.push_back(button);
GameObjects.AddObject(button);
offset += w * (1 / 9.0f);
// peacock button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
button = bFactory.Spawn(buttonID++, x, y, 51, 75.0f, 75.0f, 0.75f);
dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("peacocksfx.ogg");
classButt.push_back(button);
GameObjects.AddObject(button);
offset += w * (1 / 9.0f);
// flamingo button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
button = bFactory.Spawn(buttonID++, x, y, 52, 75.0f, 75.0f, 0.75f);
dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("flamingosfx.ogg");
classButt.push_back(button);
GameObjects.AddObject(button);
offset += w * (1 / 9.0f);
// quail button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
button = bFactory.Spawn(buttonID++, x, y, 53, 75.0f, 75.0f, 0.75f);
dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("quailsfx.ogg");
classButt.push_back(button);
GameObjects.AddObject(button);
offset += w * (1 / 9.0f);
// turkey button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
button = bFactory.Spawn(buttonID++, x, y, 54, 75.0f, 75.0f, 0.75f);
dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("turkeysfx.ogg");
classButt.push_back(button);
GameObjects.AddObject(button);
offset += w * (1 / 9.0f);
}
示例2: Awake
void ComAircraft::Awake()
{
FactoryGameObject factory;
// 컨트롤 구성요소
m_pAircraftControl = (ComAircraftControl*)gameObject->GetComponent("ComAircraftControl");
// LEVEL Text 구성요소
GameObject* pGoUITextLV = factory.CreateUIText(NULL, "UI1Text", "", 0.f, 0.f, 200.f, 100.f);
m_pTextInfo = (ComUIText*)pGoUITextLV->GetComponent("ComUIText");
GameObject* pGO = GameObject::Find("UIPanelDialog");
if (pGO != NULL)
m_pPanelUI = (ComUIPanelDialog*)pGO->GetComponent("ComUIPanelDialog");
}
示例3: playDeathSFX
void PlayerLogicComponent::playDeathSFX(int playerClass, uint64_t deadPlayerID){
//Need to pass a reference to the GameObject* associated with player who was killed
GameObject* deadPlayer = GameObjects.GetGameObject(deadPlayerID);
PlayerRenderComponent* rendComp = dynamic_cast<PlayerRenderComponent*>(deadPlayer->GetComponent(COMPONENT_RENDER));
RenderManager* renderMan = RenderManager::getRenderManager();
if (renderMan->isObjOnScreen(rendComp->objRef)){
AudioManager* audioMan = AudioManager::getAudioInstance();
switch (playerClass){
case CLASS_CHICKEN:
audioMan->playByName("chickensfx.ogg");
break;
case CLASS_PEACOCK:
audioMan->playByName("peacocksfx.ogg");
break;
case CLASS_FLAMINGO:
audioMan->playByName("flamingosfx.ogg");
break;
case CLASS_QUAIL:
audioMan->playByName("quailsfx.ogg");
break;
case CLASS_TURKEY:
audioMan->playByName("turkeysfx.ogg");
break;
case CLASS_EAGLE:
//Unimplemented
//audioMan->playByName("eaglesfx.ogg");
break;
}
}
}
示例4: rand
Game::Game(void(*Exit)())
:Exit(Exit)
{
for(int i = 0; i < 5; ++i)
{
GameObject* go = gof::CreateGameObject("assets/myGameObject.go");
SpriteRenderer* spr = (SpriteRenderer*)go->GetComponent(SPRITE_RENDERER);
spr->SetSprite(engine::SPR::TEST);
go->SetName("PIE!");
go->GetTransform().position = float2(rand() % 100, rand() % 100);
m_objects.push_back(go);
}
COMPONENT_ID list[] = {TEXT_RENDERER, MOVE_COMPONENT};
const int sizeList = sizeof(list) / sizeof(COMPONENT_ID);
GameObject* go = gof::CreateGameObject(list, sizeList);
go->SetName("FPS Counter");
m_objects.push_back(go);
COMPONENT_ID list2[] = {TEXT_RENDERER, TEST};
const int sizeList2 = sizeof(list2) / sizeof(COMPONENT_ID);
go = gof::CreateGameObject(list2, sizeList2);
go->GetTransform().position = float2(0.0f, 10.0f);
go->SetName("FUPS Counter");
m_objects.push_back(go);
}
示例5: Init
void ComCharacter::Init()
{
GameObject* pObjMap = GameObject::Find("ObjMap");
if (pObjMap != NULL)
m_pMap = (ComObjMap*)pObjMap->GetComponent("ComObjMap");
if (m_pMap)
{
m_pMap->UpdateIndexBufferQuadTree();
GetHeight();
}
m_pFollow = (ComFollowTarget*)gameObject->GetComponent("ComFollowTarget");
m_pAnimation = (ComRenderSkinnedMesh*)gameObject->GetComponent("ComRenderSkinnedMesh");
m_pChrEquipment = (ComChrEquipment*)gameObject->GetComponent("ComChrEquipment");
m_pTimerHPRec = new CTimer(CClock::GetInstance()); m_pTimerHPRec->Start();
m_pTimerMPRec = new CTimer(CClock::GetInstance()); m_pTimerMPRec->Start();
m_pTimerDamage = new CTimer(CClock::GetInstance()); m_pTimerDamage->Start();
m_pTimerCritical = new CTimer(CClock::GetInstance()); m_pTimerCritical->Start();
m_pComUIDamage = (ComText3D*)gameObject->GetComponent("ComText3D_Damage");
m_pComUICritical = (ComText3D*)gameObject->GetComponent("ComText3D_Critical");
}
示例6: destroyShield
void ChickenClassComponent::destroyShield() {
GameObject* shield = GameObjects.GetGameObject(*shieldIDs.begin());
shield->isAlive = false;
PowerShieldPhysicsComponent* physicsComp = dynamic_cast<PowerShieldPhysicsComponent*>(shield->GetComponent(COMPONENT_PHYSICS));
physicsComp->setCollisionFilter(COLLISION_POWERSHIELD, 0);
assert(!shieldIDs.empty());
shieldIDs.pop_front();
}
示例7: createClassButts
void LobbyMenu::createClassButts(){
RenderManager* renderMan = RenderManager::getRenderManager();
GameObject* tutorial;
int w, h;
float midHeight, offset;
float x, y;
renderMan->getWindowSize(&w, &h);
// height for the character class buttons
midHeight = h * (1 / 1.5f);
// finding the offset of the slots
offset = w * (1 / 14.0f);
// chicken button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
GameObject* chickButton = bFactory.Spawn(buttonID++, x, y + 10, 9150, 50.0f, 50.0f, 0.30f);
ButtonLogicComponent* chickLogic = dynamic_cast<ButtonLogicComponent*>(chickButton->GetComponent(COMPONENT_LOGIC));
ButtonRenderComponent* chickRender = dynamic_cast<ButtonRenderComponent*>(chickButton->GetComponent(COMPONENT_RENDER));
chickRender->addSecondSprite(27);
chickLogic->setSound("chickensfx.ogg");
classButt.push_back(chickButton);
GameObjects.AddObject(chickButton);
offset += w * (1 / 12.0f);
// chicken tutorial
tutorial = tFactory.Spawn(tutorialID++, 9350, 80, 0);
tutorials.push_back(tutorial);
// peacock button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
GameObject* peaButton = bFactory.Spawn(buttonID++, x, y, 9151, 50.0f, 50.0f, 0.5);
ButtonLogicComponent* peaLogic = dynamic_cast<ButtonLogicComponent*>(peaButton->GetComponent(COMPONENT_LOGIC));
ButtonRenderComponent* peaRender = dynamic_cast<ButtonRenderComponent*>(peaButton->GetComponent(COMPONENT_RENDER));
peaRender->addSecondSprite(27);
peaLogic->setSound("peacocksfx.ogg");
classButt.push_back(peaButton);
GameObjects.AddObject(peaButton);
offset += w * (1 / 11.0f);
// peacock tutorial
tutorial = tFactory.Spawn(tutorialID++, 9351,80, 0);
tutorials.push_back(tutorial);
// flamingo button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
GameObject* flamButton = bFactory.Spawn(buttonID++, x, y - 70, 9152, 59.0f, 59.0f, 0.4f);
ButtonLogicComponent* flamLogic = dynamic_cast<ButtonLogicComponent*>(flamButton->GetComponent(COMPONENT_LOGIC));
ButtonRenderComponent* flamRender = dynamic_cast<ButtonRenderComponent*>(flamButton->GetComponent(COMPONENT_RENDER));
flamRender->addSecondSprite(27);
flamLogic->setSound("flamingosfx.ogg");
classButt.push_back(flamButton);
GameObjects.AddObject(flamButton);
offset += w * (1 / 12.0f);
// flamingo tutorial
tutorial = tFactory.Spawn(tutorialID++, 9352, 80, 0);
tutorials.push_back(tutorial);
// quail button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
GameObject* quaButton = bFactory.Spawn(buttonID++, x, y + 20, 9153, 50.0f, 50.0f, 0.3f);
ButtonLogicComponent* quaLogic = dynamic_cast<ButtonLogicComponent*>(quaButton->GetComponent(COMPONENT_LOGIC));
ButtonRenderComponent* quaRender = dynamic_cast<ButtonRenderComponent*>(quaButton->GetComponent(COMPONENT_RENDER));
quaRender->addSecondSprite(27);
quaLogic->setSound("quailsfx.ogg");
classButt.push_back(quaButton);
GameObjects.AddObject(quaButton);
offset += w * (1 / 8.0f);
// quail tutorial
tutorial = tFactory.Spawn(tutorialID++, 9353, 80, 0);
tutorials.push_back(tutorial);
// turkey button
renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight);
GameObject* turkButton = bFactory.Spawn(buttonID++, x, y, 9154, 50.0f, 50.0f, 0.6f);
ButtonLogicComponent* turkLogic = dynamic_cast<ButtonLogicComponent*>(turkButton->GetComponent(COMPONENT_LOGIC));
ButtonRenderComponent* turkRender = dynamic_cast<ButtonRenderComponent*>(turkButton->GetComponent(COMPONENT_RENDER));
turkRender->addSecondSprite(27);
turkLogic->setSound("turkeysfx.ogg");
classButt.push_back(turkButton);
GameObjects.AddObject(turkButton);
offset += w * (1 / 11.0f);
// turkey tutorial
tutorial = tFactory.Spawn(tutorialID++, 9354, 80, 0);
tutorials.push_back(tutorial);
//Now assing all the controller mapping stuff
chickLogic->setNavButtons(NULL, backButt, NULL, peaButton);
peaLogic->setNavButtons(flamButton, backButt, chickButton, flamButton);
flamLogic->setNavButtons(NULL, backButt, peaButton, quaButton);
quaLogic->setNavButtons(flamButton, backButt, flamButton, turkButton);
//.........这里部分代码省略.........
示例8: Run
//.........这里部分代码省略.........
/////////////////////////////////////////////////////
bool gameloop = true;
int var = 0;
renderMan->zoom = 0.5;
float size = 6;
float ratio = 0.7f;
int armswing = (int)size;
int moveSpd = 1;
int pressed = 0;
int pressedTime = 3;
int rotation = 0;
audioMan->playByName("bgmBAAGameplay.ogg");
bool gameEndMusic = false;
int mousecounter = 5;
renderMan->zoom = 0.6f;
SystemUIObjectQueue queue;
//World Loading
GameSession::LoadWorld();
GameSession::LoadPlayers();
GameSession::LoadHUD(player, queue);
///*auto spawning minion variables
int minionCounter = 10000;
//crosshair variables
SDLRenderObject * crosshair = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 1109, -1000, -1000, -0.05f);
SDLRenderObject * crosshairCharging = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 1111, -1000, -1000, -0.05f);
crosshairCharging->visible = false;
PlayerLogicComponent* playerLogic = dynamic_cast<PlayerLogicComponent*>(player->GetComponent(COMPONENT_LOGIC));
PlayerRenderComponent* playerRend = dynamic_cast<PlayerRenderComponent*>(player->GetComponent(COMPONENT_RENDER));
//midway fountain
/*
SDLRenderObject * fount = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 101004, 40, 150, 0.005f);
fount->setScale(0.5f);
list<motion> motions;
motions.push_back(makeMotion(keyframeAnimate(fount, 0, 15), 0, 1));
Animation * runWater = new Animation(100, motions);
int aniCounter = 0;
*/
LoadBackgroundProps();
int aniCounter = 0;
bool firstTime = true;
Timing::sInstance.SetCountdownStart();
NetworkManager::sInstance->SetState(NetworkManager::NMS_Playing);
std::cout << NetworkManager::sInstance->GetState() << std::endl;
clock_t current_ticks, delta_ticks;
clock_t fps = 0;
string fpscounter = "";
SDLRenderObject * fpsHUD = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), -1, 5, 0, true);
fpsHUD->setResourceObject(renderMan->renderText(fpscounter.c_str(), 255, 0, 0, 20, "VT323-Regular"));
fpsHUD->setPos(0, 0);
SDLRenderObject * leftbaseHUDicon = nullptr;
SDLRenderObject * rightbaseHUDicon = nullptr;