-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathHOWTO.txt
67 lines (49 loc) · 1.09 KB
/
HOWTO.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Demonstration of how to use s3eIOSiCloud Marmalade extension
#include "s3eIOSiCloud.h"
struct MySaveGame
{
int a;
float b;
bool c;
};
bool isiCloudEnabled = false;
MySaveGame mySaveGame;
int MyMergeFunc(void* systemData, void*)
{
s3eIOSiCloudDataToMergeWith* data = (s3eIOSiCloudDataToMergeWith*) systemData;
// Merge incoming data with current game state
[...]
// Save locally to cache://
bool savedLocally = [...]
// Return success or failure
return savedLocally ? 0 : 1;
}
void Startup()
{
if (!s3eIOSiCloudAvailable())
return;
isiCloudEnabled =
s3eIOSiCloudRegister(S3E_IOSICLOUD_CALLBACK_MERGE, MyMergeFunc, NULL) == S3E_RESULT_SUCCESS &&
s3eIOSiCloudStart("my_save_game.txt", S3E_TRUE) == S3E_RESULT_SUCCESS;
}
void Shutdown()
{
if (isiCloudEnabled)
{
s3eIOSiCloudStop();
s3eIOSiCloudUnregister(S3E_IOSICLOUD_CALLBACK_MERGE, MyMergeFunc);
}
}
void Update()
{
if (isiCloudEnabled)
s3eIOSiCloudTick();
}
void SaveGame()
{
// Save locally to cache://
[...]
// Save to iCloud
if (isiCloudEnabled)
s3eIOSiCloudWrite(&mySaveGame, sizeof(MySaveGame));
}