How To Make a Cross-Platform Game with Cocos2D Javascript Tutorial: Getting Started
18 posts
• Page 1 of 2 • 1, 2
How To Make a Cross-Platform Game with Cocos2D Javascript Tutorial: Getting Started
This is the official thread to discuss the following blog post: How To Make a Cross-Platform Game with Cocos2D Javascript Tutorial: Getting Started
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

rwenderlich - Site Admin
- Posts: 1820
- Joined: Thu Dec 23, 2010 4:14 pm
- Has thanked: 26 times
- Been thanked: 191 times
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
God bless you Ray 
So excited to try this out! I'm doing a gameJam this weekend and my go ahead and test the JS waters with this as a guide.
I'd love to see a subsequent tutorial give an example of creating additional classes to use and how to instantiate them, but I might be able to figure that out from this.
Thank you again you're amazing.
So excited to try this out! I'm doing a gameJam this weekend and my go ahead and test the JS waters with this as a guide.
I'd love to see a subsequent tutorial give an example of creating additional classes to use and how to instantiate them, but I might be able to figure that out from this.
Thank you again you're amazing.
- grillaface
- Uber Haxx0r
- Posts: 73
- Joined: Tue Aug 02, 2011 1:59 pm
- Has thanked: 4 times
- Been thanked: 5 times
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
The tutorial looks amazingly great :]
One thing I don't really understand though - in applicationDidFinishLaunching: you fetch two times the director :
var director = cc.Director.getInstance();
and then again:
director = cc.Director.getInstance();
is the second one referring to the global "director" var, and if so would it not be better to have different names for those?
But the directory is supposed to be a singleton right, so you don't need a local and a global variable ... I'm a bit confused about this one
One thing I don't really understand though - in applicationDidFinishLaunching: you fetch two times the director :
var director = cc.Director.getInstance();
and then again:
director = cc.Director.getInstance();
is the second one referring to the global "director" var, and if so would it not be better to have different names for those?
But the directory is supposed to be a singleton right, so you don't need a local and a global variable ... I'm a bit confused about this one
-

icanzilb - iOS Tutorial Team Member
- Posts: 264
- Joined: Tue Jan 11, 2011 10:33 am
- Has thanked: 10 times
- Been thanked: 16 times
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
I have this error:
How can I change the object "nave" position in the function locationTapped ?
- Code: Select all
var navex;
var MainLayer = cc.LayerColor.extend({
_balas:[],
ctor:function() {
this._super();
cc.associateWithNative( this, cc.LayerColor );
},
onEnter:function () {
this._super();
this.setMouseEnabled(true);
var nave = cc.Sprite.create(s_nave);
nave.setPosition(winSize.width/2, nave.getContentSize().height);
this.addChild(nave);
this.schedule(this.balago, 1);
},
balago:function() {
console.log("bala");
var bala = cc.Sprite.create(s_bala);
bala.setPosition(navex, 30);
this.addChild(bala);
bala.runAction(cc.Sequence.create( // 2
cc.MoveTo.create(1, cc.p(navex,500)),
cc.CallFunc.create(function(node) {
cc.ArrayRemoveObject(this._balas, node);
node.removeFromParent();
}, this)
));
bala.setTag(1);
this._balas.push(bala);
},
onMouseUp:function (event) {
var location = event.getLocation();
this.locationTapped(location);
},
onTouchesEnded:function (touches, event) {
if (touches.length <= 0)
return;
var touch = touches[0];
var location = touch.getLocation();
this.locationTapped(location);
},
[b]locationTapped:function(location) {
nave.setPosition(0,0);
}[/b]
});
MainLayer.create = function () {
var sg = new MainLayer();
if (sg && sg.init(cc.c4b(255, 255, 255, 255))) {
return sg;
}
return null;
};
MainLayer.scene = function () {
var scene = cc.Scene.create();
var layer = MainLayer.create();
scene.addChild(layer);
return scene;
};
How can I change the object "nave" position in the function locationTapped ?
- dericeira
- n00b
- Posts: 1
- Joined: Wed Feb 27, 2013 12:35 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
I download the project and try to run in Google Chrome, but the game was not running smooth, it has some lag.
- fabiobh
- Baby Hacker
- Posts: 8
- Joined: Fri Jul 13, 2012 5:26 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
You must be psychic. Started looking at js game engines / cross platform with cocos-2dx this week then found this. great tutorial. looking forward to part 2.
- NamSin
- n00b
- Posts: 1
- Joined: Thu Feb 28, 2013 4:28 am
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
This seems to be awesome !! Actually, I was looking for a cross-platform technology for my future game in a way to code once and distribute anywhere (including web) and cocos2d-javascript seems to fill the gap. Could you compare cocos2d-javascript with Corona?
Thanks a lot!
Sam
Thanks a lot!
Sam
- samuel
- Baby Hacker
- Posts: 8
- Joined: Wed Jun 20, 2012 3:04 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
Hi Ray,
this tutorial is incredible, I can develop a web game now using my games develop with cocos2d.
Could you please extend this tutorial and cover the part about add different type of monsters?
This will help since it can introduce new concepts of cocos2d-html5
this tutorial is incredible, I can develop a web game now using my games develop with cocos2d.
Could you please extend this tutorial and cover the part about add different type of monsters?
This will help since it can introduce new concepts of cocos2d-html5
- fabiobh
- Baby Hacker
- Posts: 8
- Joined: Fri Jul 13, 2012 5:26 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
great tutorial .... can u help me? some time enemy not detect in device (iphone) if delete game again load then work but work perfect in chrome
- hamdanhashmi
- n00b
- Posts: 1
- Joined: Mon Mar 04, 2013 8:46 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: How To Make a Cross-Platform Game with Cocos2D Javascrip
Man, this is a timely tutorial!
Could use a little advice here on my own workflow. I've been using cocos2d-iphone for a while, love it, and now making jump to [fill in the blank] to go cross-platform. Just trying out some stuff this week, and have been working on a flow like described here: http://www.raywenderlich.com/23996/intr ... cosbuilder
In a nutshell here's what I'm doing-
1. Start in cocosbulider 3.0 as a javascript project. Rough in all the scenes.
2. Move over to xcode, create a cocos2d-x-javascript project from template. (v2.1rcA0) Add all the cocosbuilder stuff to the project.
3. Write classes and game logic there in xcode.
4. Wire back up with cocosbuilder
5. Test running in simulator and cocosplayer (which is really cool!)
So, a couple questions here because I'm not sure I'm in new territory here, and like you said, the documentation is a little scant and a lot of underlying things are changing rapidly:
1. Is it "better" to start in cocosbuilder or xcode, or does it matter?
2. Getting a ton of warnings in xcode on the javascript project, even on base template project. Assuming this is spidermonkey related but maybe not?
3. Interested if anyone is folding in levelhelper (also checking out codehelper) into this kind of workflow, and what I should look out for if I'm trying to do that.
Totally bonus question: I'm a novice at Git, but what I dream about sometimes is the ability to write a script that will run inside the IDE that goes out and pulls down most recent stable release of all these frameworks I'm now using and adds them to the project. Oh, and pulls in new art from dropbox
Could use a little advice here on my own workflow. I've been using cocos2d-iphone for a while, love it, and now making jump to [fill in the blank] to go cross-platform. Just trying out some stuff this week, and have been working on a flow like described here: http://www.raywenderlich.com/23996/intr ... cosbuilder
In a nutshell here's what I'm doing-
1. Start in cocosbulider 3.0 as a javascript project. Rough in all the scenes.
2. Move over to xcode, create a cocos2d-x-javascript project from template. (v2.1rcA0) Add all the cocosbuilder stuff to the project.
3. Write classes and game logic there in xcode.
4. Wire back up with cocosbuilder
5. Test running in simulator and cocosplayer (which is really cool!)
So, a couple questions here because I'm not sure I'm in new territory here, and like you said, the documentation is a little scant and a lot of underlying things are changing rapidly:
1. Is it "better" to start in cocosbuilder or xcode, or does it matter?
2. Getting a ton of warnings in xcode on the javascript project, even on base template project. Assuming this is spidermonkey related but maybe not?
3. Interested if anyone is folding in levelhelper (also checking out codehelper) into this kind of workflow, and what I should look out for if I'm trying to do that.
Totally bonus question: I'm a novice at Git, but what I dream about sometimes is the ability to write a script that will run inside the IDE that goes out and pulls down most recent stable release of all these frameworks I'm now using and adds them to the project. Oh, and pulls in new art from dropbox
18 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: zd9 and 2 guests