0

ステージカーソルを none に設定したとき。shape's( Startscreen.startButton) 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;
}

即時更新: すべてを削除して、オンロードにそのまま残してinitStartscreen()も機能しません。

メインメニューからナビゲートして使用すると機能するハイスコアレイヤーに戻るボタンを作成したため、レイヤーの問題か何かである必要があります。しかし、ゲームをプレイして同じページ/機能に移動した後、戻るボタンが機能しません。

おそらく一番上に追加したレイヤーを常に取得する方法はありますか?

4

1 に答える 1