예제 #1
0
int32 changeVarValue(void *v1, void *v2)
{
    StateManager *stateManager = (StateManager *)v1;
    EventCallback *callbackData = (EventCallback *)v2;
    StateVariable curVal = stateManager->GetStateVar(FLOAT_VAR_HANDLE);
    curVal.floatValue += 1.1f;
    stateManager->SetStateVar(FLOAT_VAR_HANDLE, curVal);

    curVal.intValue = (int)curVal.floatValue;
    stateManager->SetStateVar(INT_VAR_HANDLE, curVal);
    stateManager->PostFutureEvent("FloatChange", NULL, callbackData->gameTime + 3000);
    return 0;
}
예제 #2
0
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);
}