Я создал меню Пуск с. Это меню «Пуск» и маленькая игра должны реагировать на windows изменения размера.
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
Но когда я пишу меню «Пуск» дополнительным способом, меню «Пуск» не реагирует на размер окна. Я решил проблему, так как написал все в функции draw()
. Вы можете увидеть ниже мое решение. Но как я могу написать 'startMenu' и 'howToPlayMenu' в методе, и что эти методы реагируют, когда я изменяю размер окна. Как я уже сказал, этот код ниже работает нормально, когда я изменяю размер windows. Но когда я написал это методом, это не сработало.
function startMenu() {
hide = false;
}
function howToPlay() {
hide = true;
}
function draw() {
if (!started) {
if (!hide) {
background(back);
fill(255);
textSize(28);
text('Click me', width / 8, height / 3);
playButton.show();
playButton.position(width / 4, height / 2);
playButton.size(150, 65);
playButton.style("font-size:50px");
playButton.mousePressed(start);
levelSelectorSlider.show();
levelSelectorSlider.position(2 * width / 3 - 50, height / 2 - 100);
textSize(28);
text("Set level", 2 * width / 3 - 20, height / 2 - 120);
textSize(20)
text("Easy", 2 * width / 3 - 70, height / 2 - 50);
text("Medium", 2 * width / 3, height / 2 - 50);
text("Hard", 2 * width / 3 + 90, height / 2 - 50);
highScoreButton.show();
highScoreButton.position(2 * width / 3 - 50, height / 2);
highScoreButton.size(160, 40);
highScoreButton.style("font-size:20px");
highScoreButton.mousePressed(start);
howToPlayButton.show();
howToPlayButton.position(2 * width / 3 - 50, height / 2 + 100);
howToPlayButton.size(160, 40);
howToPlayButton.style("font-size:20px");
howToPlayButton.mousePressed(howToPlay);
goBackButton.hide();
}
else {
background(howToPlayImage);
playButton.hide();
highScoreButton.hide();
howToPlayButton.hide();
levelSelectorSlider.hide();
goBackButton.show();
goBackButton.position(50, 20);
goBackButton.size(70, 40);
goBackButton.style("font-size:20px");
goBackButton.mousePressed(startMenu);
}
}
else {
//startMenu();
background(gameBackground);
....
}
}