Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the lifecycle of gamee session? #16

Open
kirillbunin opened this issue Sep 29, 2017 · 1 comment
Open

What is the lifecycle of gamee session? #16

kirillbunin opened this issue Sep 29, 2017 · 1 comment

Comments

@kirillbunin
Copy link

I'm trying to figure out how to implement replays and ghost mode and I'm having trouble understanding it.

I imagine I will listen to event "start" for event.detail.opt_replay or event.detail.opt_ghostMod but then I have trouble figuring out, where I would store the data necessary for replication moves of the player/ghost.
In the docs, there is:

    var saveState = data.saveState;  // contains data you previously saved
    var replayData = data.replayData;
    var ghostData = data.ghostData;
    var socialData = data.socialData;

for gamee.gameInit but for gamee.gameOver there is only mentioning of storing one object. I need to store some user personalisations/progress like in game Basketball Bunny and I want to avoid conflicts/confusion in Ghost Mode between data of the user playing, and data of the ghost player.

Any additional docs would be appreciated.

@EntityB
Copy link
Contributor

EntityB commented Sep 30, 2017

Things said shortly before we update the documentation.

The original idea was the data for the replays and the ghost modes will be exactly the same. So when the gamee.gameOver occures you store just one data available for both features.

In the doc there is (was) a mistake. This doesn't exist: var ghostData = data.ghostData;

===

To your question, to store the personalized data of the current player use the gamee.gameSave method anytime during the gameplay. The next time this and only this player will play the game will receive the data as

var saveState = data.saveState; // contains data you previously saved

The recommended strategy is to call this method after each significant progress. Specifically in the Bunny game, each time player finishes the mach gamee.gameSave is called, then each time player spends the ingame coins to buy a ball for example.

To store the replay|ghost mode data the game must call the gamee.gameOver which also terminates the game. Then playing the replay|ghost mode will be available to other players from the GAMEE feed. There is one condition it will appear in the feed only if it is the highest reached score of this player in that game.

Once another player selects to play the ghost mode from the feed, upon the start the game will receive in the game.gameInit:

var saveState = data.saveState; // personalized data of the current player
var replayData = data.replayData; // data to replicate the ghost mode|replay of another player

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants