質問編集履歴
2
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
activate() {
|
|
78
|
-
let array =
|
|
78
|
+
let array =this.array;
|
|
79
79
|
|
|
80
80
|
this.panels.forEach(panel => {
|
|
81
81
|
const item = array.splice(Math.floor(Math.random() * array.length), 1)[0];
|
1
説明の追加
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
ドットインストールというサイトを参考にして、タッチゲームを作成しています。
|
|
2
2
|
|
|
3
3
|
**作りたいもの**
|
|
4
|
-
「1月~12月の英語を順にタッチしていくゲームで、
|
|
4
|
+
「1月~12月」の英語を順にタッチしていくゲームで、
|
|
5
5
|
jsの一番下行の選択肢の配列を変えるだけで、さまざまな内容のものを順番でタッチできるゲームを作りたい。
|
|
6
6
|
|
|
7
7
|
**詰まっているところ**
|
|
8
|
-
①スタートを2回以上
|
|
8
|
+
①スタートを2回以上押す(Gameクラスのbtn.addEventListenerを実行する)と、Boardクラスで定義した「array」が空になる。
|
|
9
9
|
②Panelクラスで定義した「originalarray」が空になる。
|
|
10
10
|
|
|
11
11
|
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
16
|
{
|
|
17
|
-
//クラス1―――――――――――――――――――――――――――
|
|
17
|
+
//クラス1(Panelクラス)―――――――――――――――――――――――――――
|
|
18
18
|
class Panel {
|
|
19
19
|
|
|
20
20
|
constructor(game) {
|
|
21
21
|
this.game = game;
|
|
22
22
|
this.el = document.createElement('li');
|
|
23
23
|
this.el.classList.add('pressed');
|
|
24
|
-
//ここが空になっています
|
|
24
|
+
//↓ここが空になっています
|
|
25
25
|
this.originarray = game.gettheme();
|
|
26
26
|
this.el.addEventListener('click', () => {
|
|
27
27
|
this.check();
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
//クラス2―――――――――――――――――――――――――――
|
|
53
|
+
//クラス2(Boardクラス)―――――――――――――――――――――――――――
|
|
54
54
|
class Board {
|
|
55
55
|
|
|
56
56
|
constructor(game) {
|
|
57
57
|
this.game = game;
|
|
58
58
|
this.panels = [];
|
|
59
|
-
//ここが、btnを2回押すと空になっています
|
|
59
|
+
//↓ここが、btnを2回押すと空になっています
|
|
60
60
|
this.array = game.gettheme()
|
|
61
61
|
for (let i = 0; i < this.game.gettheme().length; i++) {
|
|
62
62
|
this.panels.push(new Panel(this.game));
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
//クラス3―――――――――――――――――――――――――――
|
|
90
|
+
//クラス3(Gameクラス)―――――――――――――――――――――――――――
|
|
91
91
|
class Game {
|
|
92
92
|
constructor(theme) {
|
|
93
93
|
this.theme = theme;
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
this.currentnum = undefined;
|
|
96
96
|
|
|
97
97
|
const btn = document.getElementById('btn');
|
|
98
|
+
//↓下の処理が、スタートを押したときの処理です。
|
|
98
99
|
btn.addEventListener('click', () => {
|
|
99
100
|
this.start();
|
|
100
101
|
});
|