Xtralife wants to make sure that everyone can use our tools easily.
You’ll learn how to use the following features of Xtralife:
- Login (anonymous or with Facebook),
- Virtual File System to handle player data persistence
Get the SDK and sample project
If you have node.js installed, you can run the sample easily
Now open (it won’t work yet) http://localhost:8080/
Dive into the code
Open an account at https://account.clanofthecloud.com, and create your first game (call it sample for instance), to get an API key and API secret. You’ll need them in the next step.
Now copy/paste the Key and Secret at the very beginning of
./sample/js/sample.jsinto the corresponding variables. This tells your app how to authenticate your game to the backend.
You’ll notice a few things:
./lib/bundle.min.js(you’ll need your own copy in your own game). You can use
./lib/bundle.jsif you need more debugging information.
bundle.min.jsscript is included on every web page of the sample (except index.html which does use the backend). The script exposes a global window.Clan object.
- the sample includes a Login with Facebook feature which only works if you have a web server running on the “localhost” domain
- LocalStorage is used to store authentication information (see
./sample/js/sample-*.jsfiles show how to use each feature
This sample is minimalist in terms of toolchain and structure, and doesn’t reflect any good practices of game development for the sake of simplicity.
Start your own game
From the sample, you’ve learnt a few things that’ll be required to start your own game :
- you need a copy of
- we add no dependencies except this file
- the SDK is exposed as window.global
- player authentication/identification must be persisted (in LocalStorage for example)
- our JS SDK is as powerful as our C# SDK, and often simpler
- the SDK is open source. It’s written in Coffeescript but it should read very easily. It’s almost a one-to-one mapping to our REST APIs.
Now get back to your code!
Waiting for your feedback on Twitter : @XtraLifeCloud