Content:
- Prerequisites
- Loom Cocos SDK
- Generate Cocos SDK
- Install Loom
- Install Cocos Creator
- Integrate to Creator Game
- Sample
- Notice
Prerequisites
- Python 2.7
- Git
- NodeJS, NPM
- Loom, Install Steps
- Cocos Creator
- Cocos Loom SDK Repo
Loom Cocos SDK
Loom global structure diagram
Loom Cocos SDK structure diagram
Loom-Cocos-SDK
have the same API, same protobuf, similar contract with loom-js
.
Loom Cocos SDK
is based on Loom-JS, and porting it to Cocos Creator
.
Generate Cocos SDK
git clone https://github.com/loomnetwork/cocos-sdk.git
cd cocos-sdk
git submodule update --init
, update git submodule./tools/genCocoSDK.py
Loom SDK for Cocos Creator
can be found in the directory loom-cocos-sdk
, which is generated by running ./tools/genCocoSDK.py
Install Loom
curl https://raw.githubusercontent.com/loomnetwork/loom-sdk-documentation/master/scripts/get_loom.sh | sh
mkdir tmpgopath
export GOPATH=`pwd`/tmpgopath
./loom spin weave-blueprint
cd blueprint
export GOPATH=$GOPATH:`pwd`
make deps
make
cd build
../../loom init
cp ../genesis.example.json genesis.json
Run the blockchain:
# unable to start http server: listen tcp 127.0.0.1:9092: bind: address already in use
pkill blueprint # kill server first
../../loom run
Please consult the Loom SDK docs for further instruction on running your own DappChain.
Install Cocos Creator
Cocos Creator is a complete package of game development tools and workflow, including a game engine (based on Cocos2d-x), resource management, scene editing, game preview, debug and publish one project to multiple platforms.
For the first time, we introduced the entity-component structure and data-driven workflow to the Cocos2d-x family. With JavaScript, you can script your component in no time. The editor and engine extension is also made with JavaScript so you can make games and refine your tool in a single programming language.
Cocos Creator provides a few innovative, easy to use toolsets such as the UI system and Animation editor. The toolset will be expanding continuously and quickly, thanks to the open editor extension system.
You can download Cocos Creator
from here. Next, go ahead and install it.
Integrate to Creator Game
- copy the generated
Loom Cocos SDK
to your project'sasset/script
directory, and rename it toloom
- write your own
proto
file as requirements of your game e.g.sample/loomDemoForCreator
use setscore.proto, and related setscore_pb.js - write your own contract as requirements of your game and serialize your data with
setscore_pb.js
. Next, send to Loom Blockchain. For details, take a look at the SimpleContract
- invoke the API of your contract at a suitable position.
- Run
Sample:
There are two Sample
projects:
loomDemoForCreator
- a simple use case of the Loom SDK.dark-slash
- uses the Loom SDK in a real game.
Test Steps
- Update git submodule by running
git submodule update --init
. If you have done it, just skip this step. - Generate and pack
Loom Cocos SDK
, by running./tools/genCocoSDK.py
- Sync
Loom Cocos SDK
tosample/loomDemoForCreator
andsample/dark-slash
. Just run the following command:./tools/syncLoomJSToSample.py
cd
into theblueprint/build
directory and run theLoom Block Chain
services-../../loom run
. If Loom is already running on your machine, feel free to skip this step.- Open
sample/loomDemoForCreator
orsample/dark-slash
withCocos Creator
and run
Notice
- For more details on
Loom Block Chain
configuration, Contract's usage, take a look at this - Sample
dark-slash
come fromCocos Creator
Tutorial Project