Jump to content

Place Dom Elements above Canvas while using game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;


vastron
 Share

Recommended Posts

Hi guys,

I have created some input fields in the DOM and I place them above my phaser game with css. In my game I use

game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; 

so I use media queries to control the position of the input fields.

I do it like this =>

#inputs {
    position: absolute;
    top: 30%;
    left: 40%;
    width:100%;
}

@media only screen and (max-width: 560px) {
        #inputs{
        top: 35%;
        left: 20%;

transform: scale(0.8,0.8);
    }

}

But it is almost impossible to follow the Phaser scaling!If you have any tips, please share!

 

 

Link to comment
Share on other sites

I ended up creating a modal and styled it like this. My game is inside the #canvasWrapper. It now looks ok with the game scaling!

<style>
        body {
            background-color: black;
            box-sizing: border-box;
        }

        * {
            padding: 0;
            margin: 0;
        }

        #canvasWrapper {
            width: 99vw;
            height: 99vh;
            margin: 0 auto;
        }

.modal.in {
    display: flex !important;
}

.modal .modal-dialog {
    margin: auto;
}

h4 {
    text-align: center;
}

.fa-undo-alt, .fa-check {
    display: none;
}

.modal-dialog {
    z-index: 50000;
}

@media screen and (orientation: portrait) {
    body.modal-open {
        position: fixed;
    }
}

    </style>

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...