Sign in to follow this  
vastron

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!

 

 

Share this post


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>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.