Jump to content

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 */) {

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.");


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

Link to comment
Share on other sites

  • 3 weeks later...

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.

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.


  • Recently Browsing   0 members

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