0
私はアニメーションのための単純なテンプレートを最初に持っていたが、複数のテンプレートで異なる状態を持つようになったFlashプロジェクトに取り組んでいるいつ状態パターンを使用するのですか?
このため、私の更新(ENTER_FRAME)
private function update():void {
switch (state) {
case "intro":
switch(layoutState) {
case "large-images":
// do one animation
break;
case "thumbnails":
// do another animation
break;
case "text-on-top":
// do another animation
break;
}
break;
case "main":
switch(layoutState) {
case "large-images":
// do another animation
break;
case "thumbnails":
// do another animation
break;
case "text-on-top":
// do another animation
break;
}
break;
case "outro":
switch(layoutState) {
case "large-images":
break;
case "thumbnails":
break;
case "text-on-top":
break;
}
break;
}
switch(backgroundState) {
case "black":
// do something
break;
case "white":
// do something else
break;
}
}
そして、私の初期化メソッドがどのように見えるし始めている:
private function initalizeDescription() {
description = new Description();
switch(layoutState) {
case "large-images":
// do something to description here
break;
case "thumbnails":
// do something else to description here
if (backgroundState == "black") {
// do one thing
}
if (backgroundState == "white") {
// do another thing
}
break;
case "text-on-top":
// do something else to description here
break;
}
}
ループは今、このようなビットを見て始めています
私は偽コードについてお詫びしますが、実際のコードはかなり長いです。
これは状態パターンを使用するほうが良いでしょうか?そうであれば誰でもこれを実装する最良の方法の(短い)コードサンプルを提供できますか?