Class

SelectWindow

SelectWindow(callback, rowCount)

バトル・チュートリアルの選択に使うダイアログを実装するクラス.

Constructor

# new SelectWindow(callback, rowCount)

Parameters:
Name Type Description
callback function

項目が選択されたときに呼び出される関数. 引数として選択された項目のインデックスを受け取る

rowCount number

一度に表示できる最大項目数

Properties:
Name Type Description
menu Array.<string>

各項目の表示テキストをリストにしたものs

x number

表示位置のx座標

y number

表示位置のy座標

View Source nagibato.js, line 186

Extends

Methods

# action(GE, n)

項目が選択決定されたときの処理を実行する.

Parameters:
Name Type Description
GE stdgam.GameEngine

この処理に用いるGameEngine

n number

選択中の項目のインデックス

Overrides:

View Source nagibato.js, line 260

# bind(other)

actionやcancelの実行を指定したオブジェクトに委任する. すなわち, 以下の処理を行う.

  • other.action(GE, index) を実行するだけの関数を this.action に代入
  • other.cancel(GE, index) を実行するだけの関数を this.cancel に代入
Parameters:
Name Type Description
other Object

action/cancelの処理を委任されるオブジェクト

Overrides:

View Source stdtask.js, line 465

# cancel(GE, n)

選択がキャンセルされたときの処理を実行する.

Parameters:
Name Type Description
GE stdgam.GameEngine

この処理に用いるGameEngine

n number

選択中の項目のインデックス

Overrides:

View Source nagibato.js, line 269

# draw(GE, ctx)

描画処理を行う.

Parameters:
Name Type Description
GE stdgam.GameEngine

この処理に用いるGameEngine

ctx CanvasRenderingContext2D

描画に使うコンテクスト

View Source nagibato.js, line 222

# execute(GE)

1フレーム分のタスク処理を行う. より正確には, ラップされているSelectオブジェクトのexecuteを実行した後, その結果に基づき this.scroll と this.offset を更新する.

Parameters:
Name Type Description
GE stdgam.GameEngine

タスク処理に用いるGameEngine

Overrides:

View Source stdtask.js, line 399

# initScroll()

ラップされているSelectオブジェクトのindexの値を元に, this.scroll と this.offset の値を初期化する.

具体的には次のように決める.

  1. indexの値がviewCount未満なら, scroll = 0, offset = index でよい.
  2. そうでないとき, 先に offset = viewCount - 1 を決定してしまい,

それから scroll = index - offset とすればよい.

Overrides:

View Source stdtask.js, line 415

# resize(n)

項目数を変更する. これによりindexの値が範囲外になる場合, indexを max(n-1, 0) に変更し, それに合うように this.scroll, this.offset を調整する.

Parameters:
Name Type Description
n number

新しい項目数

Overrides:

View Source stdtask.js, line 431

# viewCount() → {number}

Overrides:

View Source stdtask.js, line 389

一度に表示できる選択肢の個数

number