cocos2d-js , How to host an cocos2d-js web only game?


How to host an cocos2d-js web only game?

Question:

Tag: cocos2d-js

I'm very confused. Before I run an simple webonly cocos2d-js example, I was under the impression it generates the html5 + js files so I can host it everywhere or either run offline.

But it is not the case, to run my example locally I have to start an cocos webserver which makes me wonder: Why does it need a webserver to run offline simple html5+js code? and What Do I need to host an cocos2d-js webonly game(I use IIS)?


Answer:

Your confusion comes from your assumption that just because something is HTML5 and javascript, it should be able to run locally.

That isn't always true.

There are many HTML5 features that require a webserver -- mostly for security reasons. One in particular is XMLHttpRequest which Cocos uses to load asset libraries asynchronously. For security reasons, XMLHttpRequest does not run locally unless you use a local webserver.


Related:


how to port cocos2d-js to android and iphone(ipad) in cocos code ide


android,ios,cocos2d-js
I am new cocos2d developer. I am studying cocos2d-js using cocos code Ide in windows. My programming language for cocos2d-js is javascript. Cocos code Ide provides good editing and testing enviroment to develop cocos2d-js. but I can't generate from the project in cocos code Ide to the release products...

Progress Timer Cocos JS v3


cocos2d-js
I'm newbie in cocos-js. I want to make a health bar in cocos JS and try this code. And i choose to use Progress Timer. But when i use this code, it just show the bar, no running action. What's wrong ? var healthBar = cc.ProgressTimer.create(cc.Sprite.create("health_bar1.png")); healthBar.setType(cc.PROGRESS_TIMER_TYPE_BAR); healthBar.setBarChangeRate(cc.p(1,0)); healthBar.setMidpoint(cc.p(0,0)); this.addChild(healthBar,...

How to host an cocos2d-js web only game?


cocos2d-js
I'm very confused. Before I run an simple webonly cocos2d-js example, I was under the impression it generates the html5 + js files so I can host it everywhere or either run offline. But it is not the case, to run my example locally I have to start an cocos...

Create Dynamic Body using cocos 2d js and Chipmunk


javascript,cocos2d-x,game-physics,chipmunk,cocos2d-js
I am fairly new to cocos 2d and chipmunk. So far i have managed to create a static object and add collision handler to it. But i want to create a dynamic.``this.space = space; this.sprite = new cc.PhysicsSprite("#rock.png"); var body = new cp.StaticBody(); body.setPos(pos); this.sprite.setBody(body); this.shape = new cp.BoxShape(body, this.sprite.getContentSize().width,...

xml.Unmarshal error: expected element type but have


xml,go,unmarshalling,cocos2d-js
I try to unmarshal a XML file using xml.Unmarshal of "encoding/xml" package. The XML file starts like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>frames</key> <dict> <key>0</key> <dict> <key>frame</key> <string>{{0, 0}, {81, 145}}</string> <key>offset</key> <string>{0, 0}</string>...

cocos2dx 3.3 animation implementation


c++,cocos2d-x,cocos2d-x-3.0,cocos2d-android,cocos2d-js
I am new in cocos2dx development.I almost learn all basic level of cocos2dx (version 3.3) in android using cpp language. I showing that there are lots of update over cocos2dx.org. In android I am currently developing the tetris game using cocos2dx version 3.3, I want to know what is the...

how can Cocos2d-JS read txt and update the file


javascript,cocos2d-js
I am working on a game that allows users to define a "dictionary" of question/answer pairs. Then, users can import the "dictionary" to the Game Scene and practice with the questions inside the "dictionary". The question is how can I do this with Cocos2d-JS? Or, I should use LocalStorage API?...

cc.ScrolView undefined in cocos2d-js


cocos2d-js
I tried to use ScrollView, TableView from cocos2d-js extensions and I noticed that it can't be seen! I also tried to create a class from that example but i need to use from native class!...

cc.textureCache.addImage blocking UI


cocos2d-x,cocos2d-x-3.0,cocos2d-js
I want to cache lot of textures in a running scene without blocking it, theoretically cc.textureCache.addImage do caching async if you call it the three arguments. This is not happening. Code: rainOfArrows: { _animFrames:[], loaded: function(){ console.log('>>>>>>>>>>>>>>LOAD!') }, load: function(){ /* Load all animation arrow sprites in memory & generate...

Read data saved with CCUserDefault


javascript,local-storage,cocos2d-x,cocos2d-js
I’m converting my game from cocos2d-x 2.2.3 to cocos2d-js 3.2, but the players already have saved progress using the old CCUserDefaults. Now that I have to use localStorage in cocos2d-js, how can I read the old data that was saved using CCUserDefaults? I don’t want players to lose their progress...