标签:
CoCoS 2D-JS的开发环境搭建
在Hbuilder中新建web项目,将cocos2d-js-v3.9.js复制到在js文件夹下,将project.json复制到工程的根目录下
在index.html文件中写入如下
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>Super Mario</title> 6 <script type="text/javascript"> 7 var g = g || {}; 8 </script> 9 <script src="js/cocos2d-js-v3.9.js"></script> 10 </head> 11 <body> 12 <canvas id="gameCanvas" width="400" height="224"></canvas> 13 <script src="js/resource.js" type="text/javascript" charset="utf-8"></script> 14 <script src="js/GameScene.js" type="text/javascript" charset="utf-8"></script> 15 <script src="js/main.js" type="text/javascript" charset="utf-8"></script> 16 </body> 17 </html>
新建main.js
1 window.onload = function(){ 2 cc.game.onStart = function(){ 3 4 cc.LoaderScene.preload([], function(){ 5 6 var scene = new GameScene(); 7 cc.director.runScene(scene); 8 9 }); 10 11 }; 12 13 cc.game.run(‘gameCanvas‘); 14 };
新建GameScene.js
1 var GameScene = cc.Scene.extend({ 2 3 });
基本配置就搞好了,接下来就可以开始利用Cocos2d-js开发游戏了
标签:
原文地址:http://www.cnblogs.com/crackpotisback/p/5022455.html