Skip to content

UITextButton error in draw #1499

@6jstar

Description

@6jstar

Describe the bug

UITextButton error in draw method

To Reproduce

Hello

New here, apologies if I'm missing anything and there's some issue with my code itself just let me know. Was recently messing around with UITextButton and I'm getting a null pointer exception in the draw method. Looks like UITextbutton only passes the renderer when calling draw() but container expects a renderer and a viewport. Error happens in container draw checking viewport.isDefault line 1195.

My code:

import * as me from 'melonjs';

class PlayButton extends me.UITextButton {
constructor(x, y) {
super(x, y, {
font : "PressStart2P",
text : "Play",
fillStyle : '#000000',
textAlign : "center",
textBaseline : "middle",
size : 1,
borderWidth: 200,
borderHeight: 50,
hoverOffColor: '#00FF00',
hoverOnColor: 'rgb(22, 152, 22)'
});
this.floating = false;
}

onClick(event) {
    me.state.change(me.state.PLAY);
}

}

and in my stage:

    this.playButton = new PlayButton(titleX, titleY + 100);
    this.playButton.anchorPoint.set(0.5, 0.5);
    me.game.world.addChild(this.playButton, 2);

Tried in both 19.6.0 and 19.7.0 with ms edge 149.0.4022.62

Expected behavior

Screenshots

Image

Live Example

Device (please complete the following information):

  • Device:
  • OS:
  • Browser:
  • melonJS Version:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions