当我测试或发布我的项目时,这是本教程中的拼图游戏: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;
}
我还包括了项目的截图。 screenshot
提前致谢