returnを書く場合と書かない場合の違いを教えて下さい

それぞれについて説明していきます。
2020年11月8日
ユーザー

いつも丁寧なご回答ありがとうございます。

■状況

returnを誤って drawGameoverメソッドに記入したためGAME OVERの画面が出ない状況になってしまいました。

--------------------------------------------------------------------------------
draw() {
if(this.isGameOver) {
this.drawGameover();
}
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.ball.draw();
this.paddle.draw();
}

drawGameover() {
this.ctx.font = '28px "Arial Black';
this.ctx.fillStyle = 'tomato';
this.ctx.fillText('GAME OVER', 50, 150);
return;     //ここです
}
----------------------------------------------------------------------------------------

■質問
Gameクラスの下記1〜3に関してなぜretunが記入・不記入なのか詳細を教えてもらえますでしょうか。


1. update() {
if (this.ball.getMissedStatus()) {
this.isGameOver = true;
//ここにreturn不記載理由
}

2. draw() {
if(this.isGameOver) {
this.drawGameover();
return; //ここにreturn記載理由
}

3.drawGameover() {
this.ctx.font = '28px "Arial Black';
this.ctx.fillStyle = 'tomato';
this.ctx.fillText('GAME OVER', 50, 150);
//ここにreturn不記載理由
}

以上、よろしくお願いいたします。

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?