回答編集履歴

2

誤字の修正

2017/06/23 16:08

投稿

nununuso
nununuso

スコア9

test CHANGED
@@ -172,146 +172,96 @@
172
172
 
173
173
  });
174
174
 
175
+
176
+
177
+ theScene3.setOnMousePressed(
178
+
179
+ new EventHandler<MouseEvent>()
180
+
181
+ {
182
+
183
+ public void handle(MouseEvent pe)
184
+
185
+ {
186
+
187
+ px=pe.getX();
188
+
189
+ py=pe.getY();
190
+
191
+
192
+
193
+ System.out.println("Push X=" + px + " Y=" + py);
194
+
195
+ }
196
+
197
+ });
198
+
199
+ }
200
+
201
+
202
+
203
+ void set(Group root1,Group root2,Group root3,Group root4){
204
+
205
+ num = num + 1;
206
+
207
+ theStage1.setTitle("Sceneテスト");
208
+
209
+ Image image = new Image(getClass().getResource("kimi.png").toExternalForm());
210
+
211
+ Image image2 = new Image(getClass().getResource("kimi2.png").toExternalForm());
212
+
213
+ Image image3 = new Image(getClass().getResource("manzi.png").toExternalForm());
214
+
215
+ Image image4 = new Image(getClass().getResource("manzi2.png").toExternalForm());
216
+
217
+ this.image = image;
218
+
219
+ this.image2 = image2;
220
+
221
+ this.image3 = image3;
222
+
223
+ this.image4 = image4;
224
+
225
+ //画像サイズは全て100*150
226
+
227
+
228
+
229
+ AudioClip plonkSound = new AudioClip(getClass().getResource("kimi.mp3").toExternalForm());
230
+
231
+ this.plonkSound = plonkSound;
232
+
175
233
 
176
234
 
177
- theScene2.setOnMousePressed(
178
-
179
- new EventHandler<MouseEvent>()
235
+ Canvas canvas1 = new Canvas(width, heigh);
236
+
180
-
237
+ GraphicsContext graphicsContext1 = canvas1.getGraphicsContext2D();
238
+
181
- {
239
+ graphicsContext1.drawImage(image, 100 , 100);
182
-
240
+
183
- public void handle(MouseEvent pe)
241
+ root1.getChildren().add(canvas1);
184
-
185
- {
186
-
187
- px=pe.getX();
188
-
189
- py=pe.getY();
190
-
191
-
192
-
193
- System.out.println("Push X=" + px + " Y=" + py);
194
-
195
- }
196
-
197
- });
198
242
 
199
243
 
200
244
 
201
- theScene3.setOnMousePressed(
202
-
203
- new EventHandler<MouseEvent>()
245
+ Canvas canvas2 = new Canvas(width, heigh);
246
+
204
-
247
+ GraphicsContext graphicsContext2 = canvas2.getGraphicsContext2D();
248
+
205
- {
249
+ graphicsContext2.drawImage(image2, 100 , 100);
206
-
250
+
207
- public void handle(MouseEvent pe)
251
+ root2.getChildren().add(canvas2);
208
-
209
- {
210
-
211
- px=pe.getX();
212
-
213
- py=pe.getY();
214
-
215
-
216
-
217
- System.out.println("Push X=" + px + " Y=" + py);
218
-
219
- }
220
-
221
- });
222
252
 
223
253
 
224
254
 
225
- theScene4.setOnMousePressed(
255
+ Canvas canvas3 = new Canvas(width, heigh);
256
+
226
-
257
+ GraphicsContext graphicsContext3 = canvas3.getGraphicsContext2D();
258
+
227
- new EventHandler<MouseEvent>()
259
+ graphicsContext3.drawImage(image3, 0 , 0);
228
-
229
- {
260
+
230
-
231
- public void handle(MouseEvent pe)
261
+ root3.getChildren().add(canvas3);
232
-
233
- {
234
-
235
- px=pe.getX();
236
-
237
- py=pe.getY();
238
-
239
-
240
-
241
- System.out.println("Push X=" + px + " Y=" + py);
242
-
243
- }
244
-
245
- });
246
-
247
-
248
-
249
- }
250
-
251
-
252
-
253
- void set(Group root1,Group root2,Group root3,Group root4){
254
-
255
- num = num + 1;
256
-
257
- theStage1.setTitle("Sceneテスト");
258
-
259
- Image image = new Image(getClass().getResource("kimi.png").toExternalForm());
260
-
261
- Image image2 = new Image(getClass().getResource("kimi2.png").toExternalForm());
262
-
263
- Image image3 = new Image(getClass().getResource("manzi.png").toExternalForm());
264
-
265
- Image image4 = new Image(getClass().getResource("manzi2.png").toExternalForm());
266
-
267
- this.image = image;
268
-
269
- this.image2 = image2;
270
-
271
- this.image3 = image3;
272
-
273
- this.image4 = image4;
274
-
275
- //画像サイズは全て100*150
276
-
277
-
278
-
279
- AudioClip plonkSound = new AudioClip(getClass().getResource("kimi.mp3").toExternalForm());
280
-
281
- this.plonkSound = plonkSound;
282
262
 
283
263
 
284
264
 
285
- Canvas canvas1 = new Canvas(width, heigh);
286
-
287
- GraphicsContext graphicsContext1 = canvas1.getGraphicsContext2D();
288
-
289
- graphicsContext1.drawImage(image, 100 , 100);
290
-
291
- root1.getChildren().add(canvas1);
292
-
293
-
294
-
295
- Canvas canvas2 = new Canvas(width, heigh);
296
-
297
- GraphicsContext graphicsContext2 = canvas2.getGraphicsContext2D();
298
-
299
- graphicsContext2.drawImage(image2, 100 , 100);
300
-
301
- root2.getChildren().add(canvas2);
302
-
303
-
304
-
305
- Canvas canvas3 = new Canvas(width, heigh);
306
-
307
- GraphicsContext graphicsContext3 = canvas3.getGraphicsContext2D();
308
-
309
- graphicsContext3.drawImage(image3, 0 , 0);
310
-
311
- root3.getChildren().add(canvas3);
312
-
313
-
314
-
315
265
  Canvas canvas4 = new Canvas(width, heigh);
316
266
 
317
267
  GraphicsContext graphicsContext4 = canvas4.getGraphicsContext2D();

1

コードのhennkou

2017/06/23 16:08

投稿

nununuso
nununuso

スコア9

test CHANGED
@@ -1,3 +1,5 @@
1
+ ```java
2
+
1
3
  package novelgame;
2
4
 
3
5
 
@@ -26,20 +28,36 @@
26
28
 
27
29
 
28
30
 
29
- public class test3 extends Application
31
+ public class test5 extends Application
30
32
 
31
33
  {
32
34
 
35
+ int num = 1;
36
+
37
+ int count = 0;
38
+
39
+ double px,py= 0;
40
+
41
+
42
+
43
+ Stage theStage1;
44
+
45
+ Image image;
46
+
47
+ Image image2;
48
+
49
+ Image image3;
50
+
51
+ Image image4;
52
+
53
+ AudioClip plonkSound;
54
+
55
+
56
+
33
57
  static int width = 512;
34
58
 
35
59
  static int heigh = 256;
36
60
 
37
- int num = 1;
38
-
39
- int count = 1;
40
-
41
- double pw,pv= 0;
42
-
43
61
 
44
62
 
45
63
  public static void main(String[] args)
@@ -54,47 +72,35 @@
54
72
 
55
73
  @Override public void start(Stage theStage)
56
74
 
57
- {
75
+ {
58
-
59
- theStage.setTitle("てすと");
76
+
60
-
61
- Image image = new Image(getClass().getResource("kimi.png").toExternalForm());
62
-
63
- Image image2 = new Image(getClass().getResource("kimi2.png").toExternalForm());
64
-
65
- Image image3 = new Image(getClass().getResource("manzi.png").toExternalForm());
66
-
67
- Image image4 = new Image(getClass().getResource("manzi2.png").toExternalForm());
68
-
69
- //画像サイズは全て100*150
70
-
71
-
72
-
73
- AudioClip plonkSound = new AudioClip(getClass().getResource("kimi.mp3").toExternalForm());
74
-
75
-
76
-
77
- Group root = new Group();
77
+ Group root1 = new Group();
78
-
78
+
79
- Canvas canvas = new Canvas(width, heigh);
79
+ Group root2 = new Group();
80
-
81
- GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
80
+
82
-
83
- graphicsContext.drawImage(image, 100 , 100);
84
-
85
- root.getChildren().add(canvas);
81
+ Group root3 = new Group();
82
+
86
-
83
+ Group root4 = new Group();
84
+
85
+
86
+
87
- Scene theScene = new Scene(root);
87
+ Scene theScene1 = new Scene(root1);
88
+
88
-
89
+ Scene theScene2 = new Scene(root2);
90
+
91
+ Scene theScene3 = new Scene(root3);
92
+
93
+ Scene theScene4 = new Scene(root4);
94
+
95
+
96
+
97
+ this.theStage1 = theStage;
98
+
89
- theStage.setWidth(280);
99
+ theStage1.setWidth(280);
90
-
100
+
91
- theStage.setHeight(280);
101
+ theStage1.setHeight(280);
92
-
93
- theStage.setScene(theScene);
102
+
94
-
95
-
96
-
97
- theStage.show();
103
+ theStage1.show();
98
104
 
99
105
 
100
106
 
@@ -114,112 +120,294 @@
114
120
 
115
121
  case 1:
116
122
 
117
- if(pw>100 && pw<250 && pv>100 && pv<200){
118
-
119
- pw = 0;
120
-
121
- pv = 0;
122
-
123
- System.out.println("ボタン1が押されたよ");
124
-
125
- graphicsContext.drawImage(image2, 100 , 100);
126
-
127
- count = count + 1;
128
-
129
- }else{
130
-
131
- graphicsContext.drawImage(image, 100 , 100);
132
-
133
- }
123
+ set(root1,root2,root3,root4);
124
+
125
+ break;
126
+
127
+
128
+
129
+ case 2:
130
+
131
+ botten1(theScene1,theScene2);
132
+
133
+ break;
134
+
135
+
136
+
137
+ case 3:
138
+
139
+ botten2(theScene3,theScene4);
140
+
141
+ break;
142
+
143
+ }
144
+
145
+
146
+
147
+ }
148
+
149
+ }.start();
150
+
151
+
152
+
153
+ theScene1.setOnMousePressed(
154
+
155
+ new EventHandler<MouseEvent>()
156
+
157
+ {
158
+
159
+ public void handle(MouseEvent pe)
160
+
161
+ {
162
+
163
+ px=pe.getX();
164
+
165
+ py=pe.getY();
166
+
167
+
168
+
169
+ System.out.println("Push X=" + px + " Y=" + py);
170
+
171
+ }
172
+
173
+ });
174
+
175
+
176
+
177
+ theScene2.setOnMousePressed(
178
+
179
+ new EventHandler<MouseEvent>()
180
+
181
+ {
182
+
183
+ public void handle(MouseEvent pe)
184
+
185
+ {
186
+
187
+ px=pe.getX();
188
+
189
+ py=pe.getY();
190
+
191
+
192
+
193
+ System.out.println("Push X=" + px + " Y=" + py);
194
+
195
+ }
196
+
197
+ });
198
+
199
+
200
+
201
+ theScene3.setOnMousePressed(
202
+
203
+ new EventHandler<MouseEvent>()
204
+
205
+ {
206
+
207
+ public void handle(MouseEvent pe)
208
+
209
+ {
210
+
211
+ px=pe.getX();
212
+
213
+ py=pe.getY();
214
+
215
+
216
+
217
+ System.out.println("Push X=" + px + " Y=" + py);
218
+
219
+ }
220
+
221
+ });
222
+
223
+
224
+
225
+ theScene4.setOnMousePressed(
226
+
227
+ new EventHandler<MouseEvent>()
228
+
229
+ {
230
+
231
+ public void handle(MouseEvent pe)
232
+
233
+ {
234
+
235
+ px=pe.getX();
236
+
237
+ py=pe.getY();
238
+
239
+
240
+
241
+ System.out.println("Push X=" + px + " Y=" + py);
242
+
243
+ }
244
+
245
+ });
246
+
247
+
248
+
249
+ }
250
+
251
+
252
+
253
+ void set(Group root1,Group root2,Group root3,Group root4){
254
+
255
+ num = num + 1;
256
+
257
+ theStage1.setTitle("Sceneテスト");
258
+
259
+ Image image = new Image(getClass().getResource("kimi.png").toExternalForm());
260
+
261
+ Image image2 = new Image(getClass().getResource("kimi2.png").toExternalForm());
262
+
263
+ Image image3 = new Image(getClass().getResource("manzi.png").toExternalForm());
264
+
265
+ Image image4 = new Image(getClass().getResource("manzi2.png").toExternalForm());
266
+
267
+ this.image = image;
268
+
269
+ this.image2 = image2;
270
+
271
+ this.image3 = image3;
272
+
273
+ this.image4 = image4;
274
+
275
+ //画像サイズは全て100*150
276
+
277
+
278
+
279
+ AudioClip plonkSound = new AudioClip(getClass().getResource("kimi.mp3").toExternalForm());
280
+
281
+ this.plonkSound = plonkSound;
282
+
283
+
284
+
285
+ Canvas canvas1 = new Canvas(width, heigh);
286
+
287
+ GraphicsContext graphicsContext1 = canvas1.getGraphicsContext2D();
288
+
289
+ graphicsContext1.drawImage(image, 100 , 100);
290
+
291
+ root1.getChildren().add(canvas1);
292
+
293
+
294
+
295
+ Canvas canvas2 = new Canvas(width, heigh);
296
+
297
+ GraphicsContext graphicsContext2 = canvas2.getGraphicsContext2D();
298
+
299
+ graphicsContext2.drawImage(image2, 100 , 100);
300
+
301
+ root2.getChildren().add(canvas2);
302
+
303
+
304
+
305
+ Canvas canvas3 = new Canvas(width, heigh);
306
+
307
+ GraphicsContext graphicsContext3 = canvas3.getGraphicsContext2D();
308
+
309
+ graphicsContext3.drawImage(image3, 0 , 0);
310
+
311
+ root3.getChildren().add(canvas3);
312
+
313
+
314
+
315
+ Canvas canvas4 = new Canvas(width, heigh);
316
+
317
+ GraphicsContext graphicsContext4 = canvas4.getGraphicsContext2D();
318
+
319
+ graphicsContext4.drawImage(image4, 0 , 0);
320
+
321
+ root4.getChildren().add(canvas4);
322
+
323
+ }
324
+
325
+
326
+
327
+ void botten1(Scene theScene1,Scene theScene2){
328
+
329
+ // pw = 110;
330
+
331
+ // pv = 110;
332
+
333
+ if(px>100 && px<250 && py>100 && py<200){
334
+
335
+ px = 0;
336
+
337
+ py = 0;
338
+
339
+ System.out.println("ボタン1が押されたよ");
340
+
341
+ theStage1.setScene(theScene2);
342
+
343
+ count = count + 1;
344
+
345
+ }else{
346
+
347
+ theStage1.setScene(theScene1);
348
+
349
+ }
134
350
 
135
351
 
136
352
 
137
353
  if(count == 3){
138
354
 
139
- graphicsContext.clearRect(0, 0, width, heigh);
140
-
141
355
  count = 0;
142
356
 
357
+ num = 3;
358
+
359
+ System.out.println("ボタン2へ移動");
360
+
361
+ }
362
+
363
+ }
364
+
365
+
366
+
367
+ void botten2(Scene theScene3,Scene theScene4){
368
+
369
+ // pw = 10;
370
+
371
+ // pv = 10;
372
+
373
+ if(px>0 && px<150 && py>0 && py<100){
374
+
375
+ px = 0;
376
+
377
+ py = 0;
378
+
379
+ System.out.println("ボタン2が押されたよ");
380
+
381
+ System.out.println("音楽スタート");
382
+
383
+ plonkSound.play();
384
+
385
+ theStage1.setScene(theScene4);
386
+
387
+ count = count + 1;
388
+
389
+ }else{
390
+
391
+ theStage1.setScene(theScene3);
392
+
393
+ }
394
+
395
+
396
+
397
+ if(count == 3){
398
+
399
+ count = 0;
400
+
143
401
  num = 2;
144
402
 
403
+ System.out.println("ボタン1へ移動");
404
+
145
- }
405
+ }
146
-
147
- break;
406
+
148
-
149
- case 2:
150
-
151
- if(pw>0 && pw<150 && pv>0 && pv<100){
152
-
153
- pw = 0;
154
-
155
- pv = 0;
156
-
157
- System.out.println("ボタン2が押されたよ");
158
-
159
- graphicsContext.drawImage(image4, 0 , 0);
160
-
161
- System.out.println("音楽スタート");
162
-
163
- plonkSound.play();
164
-
165
- count = count + 1;
166
-
167
- }else{
168
-
169
- graphicsContext.drawImage(image3, 0 , 0);
170
-
171
- }
407
+ }
172
-
173
-
174
-
175
- if(count == 3){
408
+
176
-
177
- graphicsContext.clearRect(0, 0, width, heigh);
409
+
178
-
179
- count = 0;
410
+
180
-
181
- num = 1;
182
-
183
- }
411
+ }
184
-
185
-
186
-
187
- break;
412
+
188
-
189
- }
190
-
191
-
192
-
193
- }
194
-
195
- }.start();
196
-
197
-
198
-
199
- theScene.setOnMousePressed(
200
-
201
- new EventHandler<MouseEvent>()
202
-
203
- {
204
-
205
- public void handle(MouseEvent pe)
206
-
207
- {
208
-
209
- pw=pe.getX();
210
-
211
- pv=pe.getY();
212
-
213
-
214
-
215
- System.out.println("Push X=" + pw + " Y=" + pv);
216
-
217
- }
218
-
219
- });
413
+ ```
220
-
221
-
222
-
223
- }
224
-
225
- }