Sign in to follow this  
Growler

GUI elements this.opacity, and click event doesn't work on different resolution

Recommended Posts

I borrowed the code from http://melonjs.github.io/melonJS/examples/platformer/#debug to create my own game. I'm on Melon5.1.

From that tutorial, the Tiled map is 35x35px tiles, and the resolution is 800x600 (see here: https://github.com/melonjs/melonJS/blob/master/examples/platformer/js/game.js). The GUI elements (sound, joystick, etc) this.opacity change work fine.

    onOver : function (/* event */) {
        this.setOpacity(1.0);
    },

My needs are for 16x16px tilesize, and heard 1280x640 is a good resolution for this.

If I adjust to this, however, here are the issues:

Debug panel: click events no longer work.

- GUI_Object element opacity: this.opacity doesn't change even though the hover event is firing. When I move the character, all of a sudden the opacity onOut (this.setOpacity(0.5)) fires. But only once. It's as if the hover event to setOpacity is called but doesn't update the opacity under I move the character (I guess which calls animation redraw?). And what's more weird: when I have debug panel open, hover works every time on the GUI buttons. See images below.

- GUI_Object hover events: for my custom GUI element, which I've scaled to .5, .5: hover events are no longer registering. It registers when I refresh the game page, works a couple times, then stops.

Why is this? Seems quite buggy.

 

Note: resolution at 640x320, I am able to click the debug toolbar buttons. But at another multiple of 16 resolution, 1280x640, I cannot. 

        if (!me.video.init(640, 320, {wrapper : "screen", scale : "auto", scaleMethod : "fit", renderer : me.video.AUTO, subPixel : false })) {
            alert("Your browser does not support HTML5 canvas.");
            return;
        }

--------------------

Second question: me.GUI_Object doesn't accept width/height parameters. While you can set the framewidth and frameheight in settings, how can I scale the object down on screen?

GUI_Object extends sprite which extends renderable, so I should be able to do this.scale(.5, .5), right? If I do this, it scales but looks very pixelated even on the down scale.

Screen Shot 2018-02-25 at 10.43.42 PM.png

Screen Shot 2018-02-25 at 10.44.29 PM.png

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.