# new Scroll(selectObj, viewCount)
一度に表示できる選択肢の個数がviewCountであるようなインスタンスを作る.
Parameters:
| Name | Type | Description |
|---|---|---|
selectObj |
stdtask.Select
|
ラップするSelectオブジェクト (CyclicSelectなどでも可) |
viewCount |
number
|
一度に表示できる選択肢の個数 |
Properties:
| Name | Type | Description |
|---|---|---|
scroll |
number
|
現在のスクロール量 |
offset |
number
|
現在の表示区間において選択されている要素が何番目にあるか. より正確には selectObj.index == this.scroll + this.offset を満たす整数である (selectObjはコンストラクタで与えたSelectオブジェクト) |
active |
boolean
|
(stdgam.Sceneの意味で) このオブジェクトが有効か |
Methods
# action(GE, index)
actionKeyとして指定したキーが押されたときに呼び出される. デフォルトでは何もしない.
Parameters:
| Name | Type | Description |
|---|---|---|
GE |
stdgam.GameEngine
|
タスク処理を実行するために使うGameEngine |
index |
number
|
this.indexの値 |
# bind(other)
actionやcancelの実行を指定したオブジェクトに委任する. すなわち, 以下の処理を行う.
- other.action(GE, index) を実行するだけの関数を this.action に代入
- other.cancel(GE, index) を実行するだけの関数を this.cancel に代入
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Object
|
action/cancelの処理を委任されるオブジェクト |
# cancel(GE, index)
cancelKeyとして指定したキーが押されたときに呼び出される. デフォルトでは何もしない.
Parameters:
| Name | Type | Description |
|---|---|---|
GE |
stdgam.GameEngine
|
タスク処理を実行するために使うGameEngine |
index |
number
|
this.indexの値 |
# execute(GE)
1フレーム分のタスク処理を行う. より正確には, ラップされているSelectオブジェクトのexecuteを実行した後, その結果に基づき this.scroll と this.offset を更新する.
Parameters:
| Name | Type | Description |
|---|---|---|
GE |
stdgam.GameEngine
|
タスク処理に用いるGameEngine |
# initScroll()
ラップされているSelectオブジェクトのindexの値を元に, this.scroll と this.offset の値を初期化する.
具体的には次のように決める.
- indexの値がviewCount未満なら, scroll = 0, offset = index でよい.
- そうでないとき, 先に offset = viewCount - 1 を決定してしまい,
それから scroll = index - offset とすればよい.
# resize(n)
項目数を変更する. これによりindexの値が範囲外になる場合, indexを max(n-1, 0) に変更し, それに合うように this.scroll, this.offset を調整する.
Parameters:
| Name | Type | Description |
|---|---|---|
n |
number
|
新しい項目数 |