###前提・実現したいこと
processingにてクラスを使った画面遷移のプログラムを作っています
###発生している問題・エラーメッセージ
Found one too many {characters without a} to match it.
###該当のソースコード
processing
State state;
void setup() {
size(400, 400);
textSize(32);
textAlign(CENTER);
fill(255);
state = new TitleState();
}
void draw() {
background(0);
state = state.doState();
}
abstract class State {
long t_start;
float t;
State() {
t_start = millis();
}
State doState() {
t = (millis() - t_start) / 1000.0;
text(nf(t, 1, 3) + "sec.", width * 0.5, height * 0.9);
drawState();
return decideState();
}
abstract void drawState();
abstract State decideState();
}
State class
class TitleState extends State {
void drawState() {
text("Game Title", width * 0.5, height * 0.3);
text("Press 'z' key to start", width * 0.5, height * 0.7);
}
State decideState() {
if (keyPressed && key == 'z') { // if 'z' key is pressed
return new GameState(); // start game
}
return this;
}
}
class GameState extends State {
void drawState() {
text("Game (for 5 seconds)", width * 0.5, height * 0.5);
}
State decideState() {
if (t > 5) { // if ellapsed time is larger than
return new EndingState(); // go to ending
}
return this;
}
}
class EndingState extends State {
void drawState() {
text("Ending", width * 0.5, height * 0.5);
if (t > 3) {
text("Press 'a' to restart.", width * 0.5, height * 0.7);
}
}
State decideState() {
if (t > 3 && keyPressed && key == 'a') {
return new EndingState();
}
return this;
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/07 04:21