Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 添加tween.js后不会触发按钮单击事件_Javascript_Jquery_Html_Createjs_Tween - Fatal编程技术网

Javascript 添加tween.js后不会触发按钮单击事件

Javascript 添加tween.js后不会触发按钮单击事件,javascript,jquery,html,createjs,tween,Javascript,Jquery,Html,Createjs,Tween,当我在显示框之间添加代码行时,单击事件将不再触发。我的控制台中没有错误。如何解决我的问题?我做错了什么 createjs.Tween.get(directionsbox, { loop: false }).to({ x:800, y: 650 }, 4000) 完整代码 var directionsbox = new createjs.Container(); displaybox = new createjs.Shape();

当我在显示框之间添加代码行时,单击事件将不再触发。我的控制台中没有错误。如何解决我的问题?我做错了什么

 createjs.Tween.get(directionsbox, { loop: false }).to({ x:800, y: 650 }, 4000)
完整代码

  var directionsbox = new createjs.Container();
                displaybox = new createjs.Shape();
                displaybox.graphics.beginFill("#D8D8D8").drawRoundRect(0, 0, 800, 570, 2);
                displaybox.name = "DirectionsBox";
                displaybox.x = -800;
                displaybox.y = -650;

                var label = new createjs.Text("\Congratulations!  \n \nYou have Completed a three levels." + "\n \nYour score: " + totalScoresFromAllLevels + "\n \nYour sccore was submited to the Arcade. \n\n\nPlay again? Click here.", "bold 20px Arial", "#000");
                label.textAlign = "left";
                label.lineWidth = 540;
                label.y = displaybox.y + 5;
                label.x = displaybox.x + 10

                directionsbox.addChild(displaybox, label);
                self.stage.addChild(directionsbox);
                createjs.Tween.get(directionsbox, { loop: false }).to({ x:800, y: 650 }, 4000)

                var helper = new createjs.ButtonHelper(displaybox, "out", "over", "down", false, displaybox, "hit");
                helper.y = displaybox.y;
                helper.x = displaybox.x + 275
                displaybox.addEventListener("click", handleClick);
                function handleClick(event) {
                    console.log("Clicking it");
                    createjs.Sound.play("click");
                    self.stage.removeChild(directionsbox);
                    visitedUpdateScoreFunction = false;
                    incrimentLevels();
                    //initializeGame();
                    self.stage.removeAllChildren();
                    gameData.Terms = shuffle(gameData.Terms);
                    GamehasEnded = true;
                    addBackground();
                    initializeGame();
                }

与您之前报告的问题类似,这是由于您所在的区域。如果您还记得,hitArea是基于其目标定位的。因此,例如,如果您在
[0,0]
处绘制一个圆,并将其移动到
[0100]
,则命中区域应始终为
{x=0,y=0}
。如果同时偏移命中区域,则其x/y将添加到目标位置

由于您正在更改显示框的位置,并将其用作hitArea,因此当您更改x/y时,hitArea将始终添加到该位置

  • x=0,y=0
    :hitArea在
    [0,0]
  • x=100,y=0
    :hitArea在
    [200,0]
  • x=200,y=100
    :hitArea在
    [400200]
您可以使用
null
作为命中区域(它将使用自身),或者克隆显示框,并将x和y设置为0,从而轻松解决此问题

这是一个空区域。我添加了一个光标,以便您可以看到该区域的位置

这是一本书。您可以将该区域滚动到圆的右下角,以查看该区域的位置