以一张背景图为例:
var HelloWorldLayer = cc.Layer.extend({
ctor:function () { this._super();
var bg = new cc.Sprite(res.HelloWorld_png);
var size = cc.director.getWinSize();//获取屏幕大小
bg.x = size.width / 2; // x轴/2即为x轴中点
bg.y = size.height / 2; // y轴/2即为y轴中点
this.addChild(bg, 1);
return true;
}
});