Jump to content

button wrong position when scale div parent?


rossi46
 Share

Recommended Posts

On 7/18/2016 at 6:06 PM, carlosnufe said:

Can you put the code? The first that I'm thinking is you are not setting the proper context to the button. 

Here my code.

html: 

<div class="gameCanvas">
                    <div class="wrapcenter" id="wrap_center_main">
                        <div class="center" id="main-game">
                        </div>
                    </div>
                </div>

js: 

var $gameBody = $('.gameBody'),
		$gameScale = $('.gameBackground, .wrapcenter, .GameBonusX2'),
		$gameUI = $('.group-dock, .gameUI > span, .guiscale');


    var resize_init = function () {
        var bodyHeight = $(window).height(),
			bodyWidth = $(window).width(),
			prefixCSS = setup.detectPrefix(),
			portrait = bodyHeight > bodyWidth;
        $gameBody.height(bodyHeight);

        var _a = bodyWidth - setup.defaultWidth,
			_b = (_a / setup.defaultWidth) * 100,
			_c = _b / 100 + 1,
			_d = _b / 100 + 0.5,
			_e = bodyHeight - setup.defaultWidth,
			_f = (_e / setup.defaultWidth) * 100,
			_g = _f / 100 + 1;

        function orientation_portrait() {
            $gameScale.css(prefixCSS + 'transform', 'scale(' + _g + ')');
            var gui_s = _g - 0.1;
            $gameUI.css(prefixCSS + 'transform', 'scale(' + gui_s + ')');

            var _cs = ((bodyWidth - setup.defaultWidth) / setup.defaultWidth) * 100,
				cs = _cs / 100 + 1.5,
				cs = cs > 1 ? 1 : cs;


            $('.center').css(prefixCSS + 'transform', 'scale(' + cs + ')');
        }
        function orientation_landscape() {
            $gameScale.css(prefixCSS + 'transform', 'scale(' + _c + ')');
            var gui_s = _c - 0.1;
            $gameUI.css(prefixCSS + 'transform', 'scale(' + gui_s + ')');

            if (bodyHeight < 600) {
                var _cs = ((bodyHeight - setup.defaultHeight) / setup.defaultHeight) * 100,
				cs = _cs / 100 + 1.5,
				cs = cs > 1 ? 1 : cs;
                $('.center').css(prefixCSS + 'transform', 'scale(' + cs + ')');
            }
        }

        if (portrait)
            orientation_portrait();
        else
            orientation_landscape();

    };

    $(window).resize(resize_init);
    resize_init();

create game:

var config = {
    width: 1024,
    height: 1024,
    renderer: Phaser.AUTO,
    transparent: true,
    antialias: true,
    parent: "main-game",
    forceSetTimeOut: true
};

var game = new Phaser.Game(config);
var XichBichLoader = new window.XichBich.Loader();
var XichBichGame = new window.XichBich.Game();
game.state.add("XichBichLoader", XichBichLoader);
game.state.add("XichBichGame", XichBichGame);
game.state.start("XichBichLoader");

 

Link to comment
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...
 Share

  • Recently Browsing   0 members

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