We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I'm trying to make a main menu for a game I'm making, but I'll need images for the buttons. Unfortunately, when using the button() function and using all the appropriate stuff, the button works, but I can't make the button an image. If I try making the button an image, the button just displays "[Object] Object". Am I doing something wrong?
button = createButton(img5); button.position(100, 100); //test position, not final button.mousePressed(gotoGame);
Answers
I believe when you create a button, you can only assign a label: https://p5js.org/reference/#/p5/createButton
Next not tested:
You can add your button in your html code and then access it in your js:
In index.html for example:
<input id="ibut" type="image" src="submit.gif" alt="Submit">In your sketch.js:
Kf
https://forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
// https://forum.Processing.org/two/discussion/22244/ // how-do-i-make-my-button-an-image#Item_2 // GoToLoop (2017-Apr-27) "use strict"; const IMG_URL = 'assets/my_img.png'; let imgBtn; function preload() { imgBtn = createImg(IMG_URL, 'My Clickable Image'); } function setup() { imgBtn.position(100, 100).mousePressed(gotoGame); } function gotoGame() { // blah, blah, blah... }Thank you for the help, GoToLoop and kfrajer. :)