新手刚接触 按照官网教程 已经改了好多地方了,为何那个教程里面的HelloWorld,没出来呢.代码如下
index.html–>
<body style="padding:0; margin: 0; background: #000;">
<canvas id="gameCanvas" width="800" height="450"></canvas>
<script src="cocos2d.js"></script>
cocos2d.js -->
var c = {
COCOS2D_DEBUG:2, //0 to turn debug off, 1 for basic debug, and 2 for full debug
box2d:false,
chipmunk:false,
showFPS:true,
loadExtension:false,
frameRate:60,
tag:'gameCanvas', //the dom element to run cocos2d on
engineDir:'../cocos2d/',
//SingleEngineFile:'',
appFiles:[
'src/resource.js',
// 'src/myApp.js'//add your own files in order here
'src/StartScene.js'//I'm already add my file
]
};
StartScene.js --->
var StartLayer = cc.Layer.extend({
ctor:function () {
this._super();
// var size = cc.size(window.screen.width,window.screen.height);
// var size = cc.winSize;
// var size = cc.size('1280px','678px');
// alert(cc.winSize);
var helloLabel = new cc.LabelTTF("Hello World", "", 38);
// helloLabel.x = size.width / 2;
// helloLabel.y = size.height / 2;
this.addChild(helloLabel);
return true;
}
});
var StartScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new StartLayer();
this.addChild(layer);
}
});
template.zip (457.9 KB)