Hey, so I am working on a personal plugin that makes D20 dice rolls possible in RPG Maker MZ, currently under construction and largely unfinished, and I am coming across this issue.
So I want to build my own button for rolling the dice and picking a random number, and while it did work on the built-in sprites, I can't seem to get it work in the code. Whenever I click it, nothing happens and the event does not execute at all. What am I doing wrong and how can I fix this issue?
The code is right here:
createRollButton() {
const W = 180;
const H = 60;
const Y_OFFSET = 120;
const bmp = new Bitmap(W, H);
bmp.fillRect(0, 0, W, H, "rgba(50,50,50,1.0)");
bmp.strokeRect(0, 0, W, H, "rgba(255,255,255,1.0)");
bmp.fontSize = 30;
bmp.textColor = "#ffffff";
bmp.outlineColor = "rgba(0,0,0,0.8)";
bmp.outlineWidth = 4;
bmp.drawText("Roll", 0, 0, W, H, "center");
const btn = new Sprite(bmp);
btn.x = (Graphics.width >> 1) - (W / 2);
btn.y = (Graphics.height >> 1) + Y_OFFSET;
btn.interactive = true;
btn.buttonMode = true;
btn.hitArea = new PIXI.Rectangle(0, 0, W, H);
btn.on("pointertap", () => this.onRoll());
btn.on("pointerover", () => (btn.alpha = 0.8));
btn.on("pointerout", () => (btn.alpha = 1));
this.addChild(btn);
this.rollbutton = btn;
}
I appreciate any help for this!
So I want to build my own button for rolling the dice and picking a random number, and while it did work on the built-in sprites, I can't seem to get it work in the code. Whenever I click it, nothing happens and the event does not execute at all. What am I doing wrong and how can I fix this issue?
The code is right here:
createRollButton() {
const W = 180;
const H = 60;
const Y_OFFSET = 120;
const bmp = new Bitmap(W, H);
bmp.fillRect(0, 0, W, H, "rgba(50,50,50,1.0)");
bmp.strokeRect(0, 0, W, H, "rgba(255,255,255,1.0)");
bmp.fontSize = 30;
bmp.textColor = "#ffffff";
bmp.outlineColor = "rgba(0,0,0,0.8)";
bmp.outlineWidth = 4;
bmp.drawText("Roll", 0, 0, W, H, "center");
const btn = new Sprite(bmp);
btn.x = (Graphics.width >> 1) - (W / 2);
btn.y = (Graphics.height >> 1) + Y_OFFSET;
btn.interactive = true;
btn.buttonMode = true;
btn.hitArea = new PIXI.Rectangle(0, 0, W, H);
btn.on("pointertap", () => this.onRoll());
btn.on("pointerover", () => (btn.alpha = 0.8));
btn.on("pointerout", () => (btn.alpha = 1));
this.addChild(btn);
this.rollbutton = btn;
}
I appreciate any help for this!