easljs 精灵集

示例

[pcsh lang="js" tab_size="4" message="" hl_lines="" provider="manual"]

function init(){
	var stage = new createjs.Stage('gameview');
	var image = new Image();
	var data;
	var spriteSheet;
	image.src = './spritesheet.png';
	image.onload = function(e){
		var text = new createjs.Text("Hello World", "20px Arial", "#ff7700");
		stage.addChild(text);
		data = {  
			framerate: 30,
			images:[image],//图片路径  
			frames:{"regX": 0, "height": 292, "count": 64, "regY": 0, "width": 165},
			animations:
			{  
				"run": [0, 25, "run", 1.5],//[开始帧,结束帧,动画完成后的动作,速度]  
				"jump": [26, 63, "run"]  
            }  
		};
		spriteSheet = new createjs.SpriteSheet(data); 
		sprite = new createjs.Sprite(spriteSheet,'run');  
		sprite.gotoAndPlay("run");
		stage.addChild(sprite); 
		createjs.Ticker.addEventListener('tick',function(){
			stage.update();	
		});
	};
}

[/pcsh]

 

 

 

此处评论已关闭