Hey, I am having trouble having getting my button to move forward to the next screen. It keeps giving me an error message saying "Type Error: Cannot Read Properties of Undefined (reading ‘mouse’).
https://replit.com/@starvlightt/Game-Jam-Project-Gita-S
This is the problem area.:
// Checking Button Function
if (nextButton.mouse.presses()){
print("pressed");
background("paleturquoise");
text("Welcome to screen 1");
}
This is my whole code:
//Move the catcher with the left and right arrow keys to catch the falling objects.
/* VARIABLES */
let catcher, fallingObject;
let cHeight = 400
let score = 0;
let player;
let nextButton;
/* PRELOAD LOADS FILES */
function preload(){
}
/* SETUP RUNS ONCE */
function setup() {
createCanvas(400,cHeight);
player = new Sprite(200, 380, 100, 20, "kinematic");
player.color = "blue";
nextButton = new Sprite(335, 375, 100, 20, "kinematic");
}
// Screen 2 Maze Scene
function draw() {
background(224,224,224);
nextButton.color = "orange";
nextButton.text = "Done";
}
//If keys are pressed the sprite moves according to the keys
function keyPressed () {
if (keyCode === LEFT_ARROW) {
player.vel.x = -3;
} else if (keyCode === RIGHT_ARROW) {
player.vel.x = 3;
} else if (keyCode === UP_ARROW) {
player.vel.y = -3;
} else if (keyCode === DOWN_ARROW) {
player.vel.y = 3;
} else {
player.vel.x = 0;
player.vel.y = 0;
}
}
// Motion st
function keyReleased () {
player.vel.x = 0;
player.vel.y = 0;
}
// Checking Button Function
if (nextButton.mouse.presses()){
print("pressed");
background("paleturquoise");
text("Welcome to screen 1");
}