cocos2d-html5
Version:
Cocos2d-HTML5 core package
22 lines (19 loc) • 746 B
JavaScript
var SpriteBatchNode1Test = cc.Layer.extend({
init : function(){
this._super();
var batchNode = cc.SpriteBatchNode.create(res.grossini_dance_atlas_png, 50);
this.addChild(batchNode, 0, 1);
var winSize = cc.Director.getInstance().getWinSize();
var idx = 0 | (Math.random() * 14);
var x = (idx % 5) * 85;
var y = (0 | (idx / 5)) * 121;
var sprite = cc.Sprite.create(res.grossini_dance_atlas_png, cc.rect(x, y, 85, 121));
this.addChild(sprite);
sprite.setPosition(winSize.width/2, winSize.height/2);
return true;
}
});
SpriteBatchNode1Test.create = function(args){
var layer = new SpriteBatchNode1Test();
return layer.init() ? layer : null;
};