cocos2d-html5
Version:
Cocos2d-HTML5 core package
26 lines (21 loc) • 718 B
JavaScript
var LayerTest1 = cc.Layer.extend({
ctor : function(){
this._super();
var winSize = cc.Director.getInstance().getWinSize();
var layer = cc.LayerColor.create(cc.c4b(255, 0, 0, 128), 200, 200);
layer.ignoreAnchorPointForPosition(false);
layer.setPosition(winSize.width / 2, winSize.height / 2);
this.addChild(layer, 1, 1);
this.scheduleOnce(this.updateSize, 2);
},
updateSize:function(){
var l = this.getChildByTag(1);
l.setContentSize(400,400);
l.setColor(cc.c3b(0,255,0));
l.setOpacity(127);
}
});
LayerTest1.create = function(args){
var layer = new LayerTest1();
return layer.init() ? layer : null;
};