Im making a game that uses entirely buttons for every thing but i dont know have to make buttons and i need 16 buttons for the code to work but i dont know how to make even one please help me
Greetings @stazzarama,
There is an efficient solution to this: the mousePressedOver(). This simply detects if the mouse is over for the sprite.
if (mousePressedOver("sprite")) {
console.log ("do stuff")
}
However, I find this function a little buggy at times where one click can equal multiple. So personally, I use this way:
if (mouseIsOver("sprite") && mouseWentDown("leftButton")) { //checks if mouse is over the sprite and the mouse is clicked
console.log("do stuff");
}
Now if you don’t know how to make a button, just make a sprite for it.
var sprite = createSprite(200, 200)
sprite.setAnimation("button name here");
function draw () {
drawSprites();
}