Jump to content

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


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...