Skip to content

Instantly share code, notes, and snippets.

@544
Created January 2, 2015 13:25
Show Gist options
  • Save 544/bedb3e4a0ac02aee312e to your computer and use it in GitHub Desktop.
Save 544/bedb3e4a0ac02aee312e to your computer and use it in GitHub Desktop.
71 var HelloWorldScene = cc.Scene.extend({
72 onEnter:function () {
73 this._super();
74 var layer = new HelloWorldLayer();
75 this.addChild(layer);
76 }
[masato@mba-18] $ cd ~/cocos2d-js-v3.2
[masato@mba-18] $ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
[masato@mba-18] $ ./setup.py
Setting up cocos2d-x...
...
A backup file "~/.bash_profile.backup" is created for "~/.bash_profile".
Please execute command: "source ~/.bash_profile" to make added system variables take effect
diff --git a/src/app.js b/src/app.js
index 8df4e42..835c2fc 100644
--- a/src/app.js
+++ b/src/app.js
@@ -35,7 +35,7 @@ var HelloWorldLayer = cc.Layer.extend({
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
- var helloLabel = new cc.LabelTTF("Hello World", "Arial", 38);
+ var helloLabel = new cc.LabelTTF("Hello Cocos2d-JS", "Arial", 38);
// position the label on the center of the screen
helloLabel.x = size.width / 2;
helloLabel.y = 0;
[masato@mba-18] $ diff ~/.bash_profile.backup ~/.bash_profile
1a2,5
>
> # Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x
> export COCOS_CONSOLE_ROOT=~/cocos2d-js-v3.2/tools/cocos2d-console/bin
> export PATH=$COCOS_CONSOLE_ROOT:$PATH
[masato@mba-18] $
[masato@mba-18] $ which cocos
cocos not found
[masato@mba-18] $ export COCOS_CONSOLE_ROOT=/Users/masato/cocos2d-js-v3.2/tools/cocos2d-console/bin
[masato@mba-18] $ export PATH=$COCOS_CONSOLE_ROOT:$PATH
[masato@mba-18] $ which cocos
/Users/masato/cocos2d-js-v3.2/tools/cocos2d-console/bin/cocos
[masato@mba-18] $
[masato@mba-18] $ cocos new HelloWorld -l js -d ~/dev/Cocos2dJS
Running command: new
> Copy template into ~/dev/Cocos2dJS/HelloWorld
> Copying cocos2d-html5 files...
> Copying files from cocos root directory...
> Copying files from template directory...
> Copying directory from cocos root directory...
> Copying cocos2d-x files...
> Rename project name from 'HelloJavascript' to 'HelloWorld'
> Replace the project name from 'HelloJavascript' to 'HelloWorld'
> Replace the project package name from 'org.cocos2dx.hellojavascript' to 'org.cocos2dx.HelloWorld'
> Replace the mac bundle id from 'org.cocos2dx.hellojavascript' to 'org.cocos2dx.HelloWorld'
> Replace the ios bundle id from 'org.cocos2dx.hellojavascript' to 'org.cocos2dx.HelloWorld'
[masato@mba-18] $ cd ~/dev/Cocos2dJS/HelloWorld
[masato@mba-18] $ cocos run -p web
[masato@mba-18] $ tree -L 2 ~/dev/Cocos2dJS/HelloWorld
~/dev/Cocos2dJS/HelloWorld
├── CMakeLists.txt
├── frameworks
│   ├── cocos2d-html5
│   ├── js-bindings
│   └── runtime-src
├── index.html
├── main.js
├── project.json
├── res
│   ├── CloseNormal.png
│   ├── CloseSelected.png
│   ├── HelloWorld.png
│   └── favicon.ico
├── src
│   ├── app.js
│   └── resource.js
└── tools
├── bindings-generator
└── tojs
9 directories, 10 files
...
25 <script src="main.js"></script>
...
55 cc.LoaderScene.preload(g_resources, function () {
56 cc.director.runScene(new HelloWorldScene());
57 }, this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment