質問編集履歴
4
;の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -148,172 +148,172 @@
|
|
148
148
|
|
149
149
|
}
|
150
150
|
|
151
|
+
};//;を追記
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
theScene1.setOnMousePressed(
|
156
|
+
|
157
|
+
new EventHandler<MouseEvent>()
|
158
|
+
|
159
|
+
{
|
160
|
+
|
161
|
+
public void handle(MouseEvent pe)
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
pw=pe.getX();
|
166
|
+
|
167
|
+
pv=pe.getY();
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
System.out.println("Push X=" + pw + " Y=" + pv);
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
});
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
void set(){
|
184
|
+
|
185
|
+
theStage1.setTitle("てすと");
|
186
|
+
|
187
|
+
Image image = new Image(getClass().getResource("kimi.png").toExternalForm());
|
188
|
+
|
189
|
+
Image image2 = new Image(getClass().getResource("kimi2.png").toExternalForm());
|
190
|
+
|
191
|
+
Image image3 = new Image(getClass().getResource("manzi.png").toExternalForm());
|
192
|
+
|
193
|
+
Image image4 = new Image(getClass().getResource("manzi2.png").toExternalForm());
|
194
|
+
|
195
|
+
//画像サイズは全て100*150
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
AudioClip plonkSound = new AudioClip(getClass().getResource("kimi.mp3").toExternalForm());
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
Group root = new Group();
|
204
|
+
|
205
|
+
Canvas canvas = new Canvas(width, heigh);
|
206
|
+
|
207
|
+
GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
|
208
|
+
|
209
|
+
graphicsContext.drawImage(image, 100 , 100);
|
210
|
+
|
211
|
+
root.getChildren().add(canvas);
|
212
|
+
|
213
|
+
Scene theScene = new Scene(root);
|
214
|
+
|
215
|
+
this.theScene1 = theScene;
|
216
|
+
|
217
|
+
this.image = image;
|
218
|
+
|
219
|
+
this.image2 = image2;
|
220
|
+
|
221
|
+
this.image3 = image3;
|
222
|
+
|
223
|
+
this.image4 = image4;
|
224
|
+
|
225
|
+
this.graphicsContext = graphicsContext;
|
226
|
+
|
227
|
+
this.plonkSound = plonkSound;
|
228
|
+
|
229
|
+
theStage1.setWidth(280);
|
230
|
+
|
231
|
+
theStage1.setHeight(280);
|
232
|
+
|
233
|
+
theStage1.setScene(theScene1);
|
234
|
+
|
235
|
+
theStage1.show();
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
void botten1(){
|
242
|
+
|
243
|
+
while(true){
|
244
|
+
|
245
|
+
graphicsContext.clearRect(0, 0, width, heigh);
|
246
|
+
|
247
|
+
if(pw>100 && pw<250 && pv>100 && pv<200){
|
248
|
+
|
249
|
+
System.out.println("ボタン1が押されたよ");
|
250
|
+
|
251
|
+
graphicsContext.drawImage(image2, 100 , 100);
|
252
|
+
|
253
|
+
plonkSound.play();
|
254
|
+
|
255
|
+
count = count + 1;
|
256
|
+
|
257
|
+
}else{
|
258
|
+
|
259
|
+
graphicsContext.drawImage(image, 100 , 100);
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
if(count == 5){
|
264
|
+
|
265
|
+
num = 3;
|
266
|
+
|
267
|
+
count = 1;
|
268
|
+
|
269
|
+
break;
|
270
|
+
|
151
271
|
}
|
152
272
|
|
153
273
|
|
154
274
|
|
155
|
-
theScene1.setOnMousePressed(
|
156
|
-
|
157
|
-
new EventHandler<MouseEvent>()
|
158
|
-
|
159
|
-
{
|
160
|
-
|
161
|
-
public void handle(MouseEvent pe)
|
162
|
-
|
163
|
-
{
|
164
|
-
|
165
|
-
pw=pe.getX();
|
166
|
-
|
167
|
-
pv=pe.getY();
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
System.out.println("Push X=" + pw + " Y=" + pv);
|
172
|
-
|
173
|
-
|
275
|
+
}
|
174
|
-
|
175
|
-
});
|
176
|
-
|
177
|
-
|
178
276
|
|
179
277
|
}
|
180
278
|
|
181
279
|
|
182
280
|
|
183
|
-
void set(){
|
184
|
-
|
185
|
-
theStage1.setTitle("てすと");
|
186
|
-
|
187
|
-
Image image = new Image(getClass().getResource("kimi.png").toExternalForm());
|
188
|
-
|
189
|
-
Image image2 = new Image(getClass().getResource("kimi2.png").toExternalForm());
|
190
|
-
|
191
|
-
Image image3 = new Image(getClass().getResource("manzi.png").toExternalForm());
|
192
|
-
|
193
|
-
Image image4 = new Image(getClass().getResource("manzi2.png").toExternalForm());
|
194
|
-
|
195
|
-
//画像サイズは全て100*150
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
AudioClip plonkSound = new AudioClip(getClass().getResource("kimi.mp3").toExternalForm());
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
Group root = new Group();
|
204
|
-
|
205
|
-
Canvas canvas = new Canvas(width, heigh);
|
206
|
-
|
207
|
-
GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
|
208
|
-
|
209
|
-
graphicsContext.drawImage(image, 100 , 100);
|
210
|
-
|
211
|
-
root.getChildren().add(canvas);
|
212
|
-
|
213
|
-
Scene theScene = new Scene(root);
|
214
|
-
|
215
|
-
this.theScene1 = theScene;
|
216
|
-
|
217
|
-
this.image = image;
|
218
|
-
|
219
|
-
this.image2 = image2;
|
220
|
-
|
221
|
-
this.image3 = image3;
|
222
|
-
|
223
|
-
this.image4 = image4;
|
224
|
-
|
225
|
-
this.graphicsContext = graphicsContext;
|
226
|
-
|
227
|
-
this.plonkSound = plonkSound;
|
228
|
-
|
229
|
-
theStage1.setWidth(280);
|
230
|
-
|
231
|
-
theStage1.setHeight(280);
|
232
|
-
|
233
|
-
theStage1.setScene(theScene1);
|
234
|
-
|
235
|
-
theStage1.show();
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
void botten
|
281
|
+
void botten2(){
|
242
282
|
|
243
283
|
while(true){
|
244
284
|
|
245
285
|
graphicsContext.clearRect(0, 0, width, heigh);
|
246
286
|
|
247
|
-
if(pw>
|
287
|
+
if(pw>0 && pw<150 && pv>0 && pv<100){
|
248
|
-
|
288
|
+
|
249
|
-
System.out.println("ボタン
|
289
|
+
System.out.println("ボタン2が押されたよ");
|
250
|
-
|
290
|
+
|
251
|
-
graphicsContext.drawImage(image
|
291
|
+
graphicsContext.drawImage(image4, 0 , 0);
|
252
|
-
|
292
|
+
|
253
|
-
|
293
|
+
System.out.println("音楽スタート");
|
254
294
|
|
255
295
|
count = count + 1;
|
256
296
|
|
257
297
|
}else{
|
258
298
|
|
259
|
-
graphicsContext.drawImage(image,
|
299
|
+
graphicsContext.drawImage(image3, 0 , 0);
|
260
300
|
|
261
301
|
}
|
262
302
|
|
303
|
+
|
304
|
+
|
263
305
|
if(count == 5){
|
264
306
|
|
265
|
-
num = 3;
|
266
|
-
|
267
307
|
count = 1;
|
268
308
|
|
309
|
+
num = 1;
|
310
|
+
|
269
311
|
break;
|
270
312
|
|
271
313
|
}
|
272
314
|
|
273
|
-
|
274
|
-
|
275
315
|
}
|
276
316
|
|
277
|
-
}
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
void botten2(){
|
282
|
-
|
283
|
-
while(true){
|
284
|
-
|
285
|
-
graphicsContext.clearRect(0, 0, width, heigh);
|
286
|
-
|
287
|
-
if(pw>0 && pw<150 && pv>0 && pv<100){
|
288
|
-
|
289
|
-
System.out.println("ボタン2が押されたよ");
|
290
|
-
|
291
|
-
graphicsContext.drawImage(image4, 0 , 0);
|
292
|
-
|
293
|
-
System.out.println("音楽スタート");
|
294
|
-
|
295
|
-
count = count + 1;
|
296
|
-
|
297
|
-
}else{
|
298
|
-
|
299
|
-
graphicsContext.drawImage(image3, 0 , 0);
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
if(count == 5){
|
306
|
-
|
307
|
-
count = 1;
|
308
|
-
|
309
|
-
num = 1;
|
310
|
-
|
311
|
-
break;
|
312
|
-
|
313
|
-
}
|
314
|
-
|
315
|
-
}
|
316
|
-
|
317
317
|
}
|
318
318
|
|
319
319
|
}
|
3
エラーメッセージの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -320,7 +320,7 @@
|
|
320
320
|
|
321
321
|
```
|
322
322
|
|
323
|
-
- エラーメッセージ
|
323
|
+
- 追記エラーメッセージ
|
324
324
|
|
325
325
|
run:
|
326
326
|
|
2
エラーメッセージの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -318,7 +318,69 @@
|
|
318
318
|
|
319
319
|
}
|
320
320
|
|
321
|
+
```
|
322
|
+
|
323
|
+
- エラーメッセージ
|
324
|
+
|
325
|
+
run:
|
326
|
+
|
321
|
-
|
327
|
+
Exception in Application start method
|
328
|
+
|
329
|
+
java.lang.reflect.InvocationTargetException
|
330
|
+
|
331
|
+
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
332
|
+
|
333
|
+
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
334
|
+
|
335
|
+
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
336
|
+
|
337
|
+
at java.lang.reflect.Method.invoke(Method.java:498)
|
338
|
+
|
339
|
+
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
|
340
|
+
|
341
|
+
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
|
342
|
+
|
343
|
+
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
344
|
+
|
345
|
+
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
346
|
+
|
347
|
+
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
348
|
+
|
349
|
+
at java.lang.reflect.Method.invoke(Method.java:498)
|
350
|
+
|
351
|
+
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
|
352
|
+
|
353
|
+
Caused by: java.lang.RuntimeException: Exception in Application start method
|
354
|
+
|
355
|
+
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
|
356
|
+
|
357
|
+
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
|
358
|
+
|
359
|
+
at java.lang.Thread.run(Thread.java:748)
|
360
|
+
|
361
|
+
Caused by: java.lang.NullPointerException
|
362
|
+
|
363
|
+
at novelgame.test2.start(test2.java:64)
|
364
|
+
|
365
|
+
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
|
366
|
+
|
367
|
+
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
|
368
|
+
|
369
|
+
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
|
370
|
+
|
371
|
+
at java.security.AccessController.doPrivileged(Native Method)
|
372
|
+
|
373
|
+
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
|
374
|
+
|
375
|
+
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
|
376
|
+
|
377
|
+
Exception running application novelgame.test2
|
378
|
+
|
379
|
+
/Users/username/Library/Caches/NetBeans/8.2/executor-snippets/run.xml:53: Java returned: 1
|
380
|
+
|
381
|
+
ビルド失敗(合計時間: 2秒)
|
382
|
+
|
383
|
+
|
322
384
|
|
323
385
|
- 補足情報(言語/FW/ツール等のバージョンなど)
|
324
386
|
|
1
質問内容の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,6 +14,16 @@
|
|
14
14
|
|
15
15
|
(ボタン2が押された時のみ画像が変化
|
16
16
|
|
17
|
+
|
18
|
+
|
19
|
+
またゲームなどの画面切り替えの際にsceneを複数用意して条件によって切り替えるのか
|
20
|
+
|
21
|
+
scene1つだけ作りsceneの中身を条件によって変更していくのは
|
22
|
+
|
23
|
+
どちらが一般的な方法でしょうか?
|
24
|
+
|
25
|
+
贅沢な質問申し訳ありません
|
26
|
+
|
17
27
|
- 対応するコード
|
18
28
|
|
19
29
|
```java
|