0

当我测试或发布我的项目时,这是本教程中的拼图游戏:https ://www.youtube.com/watch?v=uCQuUZs3UGE

除了灰色背景,什么都没有被绘制。根本没有绘制任何拼图或任何拼图形状。我也收到警告:

警告:EaselJS 中的帧编号从 0 而不是 1 开始。例如,这会影响 gotoAndStop 和 gotoAndPlay 调用。(17)

但这应该只是一个警告,而不是错误。那么我的javascript代码中可能有错误吗?这是代码,它相当简单:

//************
// Initialize;

var numPieces = 16;

for (var i = 0; i = < numPieces; i++) 
{
	var pieceName = "p" + (i + 1);
	var piece = this[pieceName];
	if (piece)
		{
		piece.name = pieceName;
		piece.on("mousedown", function(evt) 
			{
				this.scaleX = 1;
				this.scaleY = 1;
				this.shadow = null;
				this.parent.addChild(this);
				this.offset = (x:this.x - evt.stageX, y:this.y - evt.stageY);
			});
		piece.on("pressmove", function (evt) 
			{
				this.x = evt.stageX + this.offset.x;
				this.y = evt.stageY + this.offset.y;
			});
		piece.on("pressup", function(evt) 
			{
			var target = this.parent["t"+this.name.substr(1)];
			if (target && hitTestInRange(target, 30) ) 
				{
				this.x = target.x;
				this.y = target.y;
				}
			});
		}
}

function hitTestInRange( target, range ) 
{
	if (target.x > stage.mouseX - range &&
		target.x < stage.mouseX + range &&
		target.y > stage.mouseY - range &&
		target.y < stage.mouseY + range) 
		{
			return true;
		}
	return false;
}

我还附上了该项目的屏幕截图。截屏

提前致谢

4

0 回答 0