當我將舞臺光標設置爲無。我無法以某種方式訪問我的形狀(Startscreen.startButton
)eventlistener。當我不隱藏我的光標時,我可以點擊它。當從舞臺上移除光標時,Eventlistener不在收聽
我做錯了什麼?
function initStartscreen() {
startscreenLayer = new createjs.Container();
createMenuCursor();
stage.addEventListener("stagemousemove", mouseMove);
stage.enableMouseOver(2);
stage.cursor = 'none';
Startscreen = new Startscreen();
startscreenLayer.addChild(Startscreen.background);
startscreenLayer.addChild(Startscreen.startButton);
startscreenLayer.addChild(Startscreen.startText);
startscreenLayer.addChild(Startscreen.highscoreButton);
startscreenLayer.addChild(Startscreen.highscoreText);
stage.addChildAt(startscreenLayer);
stage.update();
Startscreen.startButton.addEventListener('click', function() {
alert(1);
});
}
function Startscreen() {
this.background = new createjs.Shape();
this.background.graphics
.beginFill('pink')
.drawRect(0, 0, stage.canvas.width, stage.canvas.height);
this.startButton = new createjs.Shape();
this.startButton.graphics
.beginFill('#000')
.drawRect(0, 0, 250, 50)
this.startButton.x = (stage.canvas.width/2)-125;
this.startButton.y = 150;
this.startButton.name = "startButton";
this.startText = new createjs.Text('Start', '30px Calibri', '#FFF');
this.startText.x = this.startButton.x + 95;
this.startText.y = this.startButton.y + 7;
}
即時更新: 即使我剝離一切都關掉,只留下我的onload這是行不通的initStartscreen()
。
它必須是一些分層問題,或者因爲我在我的高分層創建了一個後退按鈕,當我從主菜單中使用它時,它會起作用。但是在玩過我的遊戲並轉到相同頁面/功能後,後退按鈕不起作用。
有沒有辦法讓我添加到頂層的圖層呢?
哈哈,很明顯,我已經得到了以下mouseX和mouseY的;-)點擊是在畫布上的東西的位圖。所以,jQuery並不是我所害怕的適合解決方案。 – CaptainCarl 2013-04-11 10:31:05