Cocos-js run in browser

Hi, I have tried to use cocos-js, but I have a question (I hope not a stupid question :slight_smile: )… On Cocos Studio the game runs perfectly in the browser etc… but if I use the app with index.html (double click) I have this error in my browser:

[Error] load json [frameworks/cocos2d-html5/moduleConfig.json] failed : load frameworks/cocos2d-html5/moduleConfig.json failed!
(funzione anonima) (CCBoot.js, line 714)
onload (CCBoot.js, line 672)

why?

Thanks!

Stefano

Do you try to run the game by double clicking index.html?
If so then it would not run and give you error which says HTTP 404 or something like this.
So, it is actually expecting you to host your game somewhere.

So, to run the game from local, go to the project directory and run command cocos run -p web
Now it will open the game in your default browser.

Ok, now… if your friend wants to run the game just upload it to server and give the index.html URL to your friend or you can also upload your game to dropbox public folder. And then give the index.html URL to your friend. But for this, it is obvious to pack your game using command cocos compile -m release -t web
And then it will generate publish folder inside your project directory. So just host this folder somewhere or upload it to dropbox public folder as told just before.

1 Like

Thanks!!

Stefano

Another question:

is it possible disable bilinear filter on sprite?

Thanks!

Hey, hi…
I am not much experienced with cocos2d-x so I could not answer your last ques.
But you may explain to me what exactly is that… I may try to figure it out using code, and if I’ll get I’ll get back to you :smile:

Just check this out… Does enabling(which gets automatically enabled when we make sprite) bilinear filtering makes your graphics get aliased?

Just see this post, it might help

On cocos2d-x c++, there is
getTexture()->setAliasTexParameters()

on cocos2d-js I have not found any thing for disable the “alias” (bilinearfilter) on the texture… there is a alternative? May be an attribute on the canvas?

Thanks!

cocos2d-x and cocos2dJS have almost similar APIs so I was wondering how could it not have… See I tried this in cocosIDE…

	var k = cc.Texture2D.setAntiAliasTexParameters();
	var k = cc.Texture2D.setAliasTexParameters();

They both are present though I don’t know how to use them exactly.

Also, if you’re trying to do sprite.getTexture().
I mean if you’re putting dot after sprite.getTexture() and then expecting auto complete to show you options setAntiAliasTextParameters() or setAliasTexParameters() then let me clear you cocosIDE auto complete still needs to be matured inorder to do auto complete for something.something.XYZ (I mean its auto complete won’t show XYZ)

So, better to find auto complete like the way I found, and now since you know that it exist, you may straight away use this after sprite.getTexture() because you know that its type is Texture2D…

So, now you want it
sprite.getTexture().setAntiAliasTexParameters()

It should work…
I don’t know how exactly it is to be used (I mean any parameters)… but this function is fine… :smile: