本文整理汇总了C++中StateManager::SubscribeStateVarChange方法的典型用法代码示例。如果您正苦于以下问题:C++ StateManager::SubscribeStateVarChange方法的具体用法?C++ StateManager::SubscribeStateVarChange怎么用?C++ StateManager::SubscribeStateVarChange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateManager
的用法示例。
在下文中一共展示了StateManager::SubscribeStateVarChange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoSimpleTest
void DoSimpleTest(GameManager *mgr, uint32 marker_handle, uint32 width, uint32 height)
{
StateManager *state = mgr->GetStateManager();
StateVariable tmpVar;
tmpVar.intValue = 21;
INT_VAR_HANDLE = state->RegisterStateVariable("IntVar", tmpVar);
tmpVar.floatValue = 3.1415f;
FLOAT_VAR_HANDLE = state->RegisterStateVariable("FloatVar", tmpVar);
tmpVar.stringValue = "Hello World!";
STRING_VAR_HANDLE = state->RegisterStateVariable("StringVar", tmpVar);
PathFollowingSprite *intPath = new PathFollowingSprite(mgr);
intPath->AddSegment(new PathSegmentBezier(CIwVec2(100,100), CIwVec2(200, 900), CIwVec2(700, -50), CIwVec2(800,600)));
intPath->SetTotalPathTimeMillis(5000);
mgr->RegisterGameObject(intPath);
CIwColour transparent;
transparent.Set(0, 0, 0, 0);
char buffer[1024];
sprintf(buffer, "Int: %d", state->GetStateVar(INT_VAR_HANDLE).intValue);
intSprite = new TextSprite(mgr, buffer);
intSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
intSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_BLUE]);
intSprite->SetBorderThickness(CIwVec2(3, 3));
intSprite->SetPadding(CIwVec2(3, 3));
intSprite->SetBaseLocation(CIwVec2(300, 100));
//intSprite->AddTransformation(new AnchorToTransformation(intPath, CIwVec2(0,0)));
//intSprite->AddTransformation(new OrbitTransformation(0, 5000));
mgr->RegisterGameObject(intSprite);
sprintf(buffer, "Float: %f", state->GetStateVar(FLOAT_VAR_HANDLE).floatValue);
floatSprite = new TextSprite(mgr, buffer);
floatSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
floatSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_GREEN]);
floatSprite->SetBorderThickness(CIwVec2(3, 3));
floatSprite->SetPadding(CIwVec2(3, 3));
floatSprite->SetBaseLocation(CIwVec2(300, 200));
mgr->RegisterGameObject(floatSprite);
sprintf(buffer, "String: %s", state->GetStateVar(STRING_VAR_HANDLE).stringValue);
stringSprite = new TextSprite(mgr, buffer);
stringSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
stringSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_CYAN]);
stringSprite->SetBorderThickness(CIwVec2(5, 5));
stringSprite->SetPadding(CIwVec2(2, 2));
stringSprite->SetBaseLocation(CIwVec2(300, 300));
mgr->RegisterGameObject(stringSprite);
sprintf(buffer, "Next string");
stringSprite = new TextSprite(mgr, buffer);
stringSprite->SetBackgroundColor(g_IwGxColours[IW_GX_COLOUR_WHITE]);
stringSprite->SetBorderColor(g_IwGxColours[IW_GX_COLOUR_BLACK]);
stringSprite->SetMargin(CIwVec2(4, 4));
stringSprite->SetBorderThickness(CIwVec2(4, 4));
stringSprite->SetPadding(CIwVec2(4, 4));
stringSprite->SetBaseLocation(CIwVec2(400, 400));
mgr->RegisterGameObject(stringSprite);
state->SubscribeStateVarChange(INT_VAR_HANDLE, stateVarChanged, intSprite);
state->SubscribeStateVarChange(FLOAT_VAR_HANDLE, stateVarChanged, floatSprite);
state->SubscribeEvent("FloatChange", changeVarValue, NULL);
state->PostFutureEvent("FloatChange", NULL, mgr->GetCurrentClockTime() + 3000);
}