GameAction API
GameAction API
A namespace for reporting the lifecycle of a single game round to the platform. All calls are fire-and-forget — there is no completion callback.
TudadaSDK.Instance.gameAction exposes three methods:
Start(payload?, additionalPayload?)— round startedComplete(payload, additionalPayload?)— round cleared normallyExit(payload, additionalPayload?)— round ended abnormally
Start(payload?, additionalPayload?)
Reports that a round has started. All arguments are optional.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
payload | GameActionStartPayload | - | Round / stage / level info |
additionalPayload | string | - | Free-form metadata |
GameActionStartPayload fields:
| Field | Type | Description |
|---|---|---|
round | int | Round number |
stage | int | Stage number |
level | int | Level number |
// No arguments
TudadaSDK.Instance.gameAction.Start();
// With stage info
TudadaSDK.Instance.gameAction.Start(
payload: new GameActionStartPayload { stage = 3 }
);
Complete(payload, additionalPayload?)
Reports that a round has been cleared normally. result and playTime are required.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
payload | GameActionCompletePayload | ✅ | Result info |
additionalPayload | string | - | Free-form metadata |
GameActionCompletePayload fields:
| Field | Type | Required | Description |
|---|---|---|---|
result | string | ✅ | "WIN" / "LOSE" / "DRAW" / "DONE" (use GameActionResult constants) |
playTime | long | ✅ | Round duration (ms) |
score | int | - | Score achieved |
round | int | - | Round number |
stage | int | - | Stage number |
level | int | - | Level number |
TudadaSDK.Instance.gameAction.Complete(
payload: new GameActionCompletePayload {
result = GameActionResult.Win,
playTime = 12345,
score = 9000,
stage = 3,
}
);
Exit(payload, additionalPayload?)
Reports that a round was ended without normal completion. playTime and reason are required.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
payload | GameActionExitPayload | ✅ | Exit info |
additionalPayload | string | - | Free-form metadata |
GameActionExitPayload fields:
| Field | Type | Required | Description |
|---|---|---|---|
playTime | long | ✅ | Round duration (ms) |
reason | string | ✅ | "TIMEOUT" / "ABANDONED" (use GameActionExitReason constants) |
// Player abandoned
TudadaSDK.Instance.gameAction.Exit(
payload: new GameActionExitPayload {
playTime = 4500,
reason = GameActionExitReason.Abandoned,
}
);
// Time limit reached
TudadaSDK.Instance.gameAction.Exit(
payload: new GameActionExitPayload {
playTime = 60000,
reason = GameActionExitReason.Timeout,
}
);
tip
Exit() should be called explicitly by the game code when it decides a round has ended. It is independent of page unload (web view close).