Optional
target: TTProtected
Optional
_generatorProtected
_isProtected
_loopProtected
_taskOptional
targetRunner対象オブジェクト
[jp] 稼働中の内部ジェネレータがあるかどうかを返す
[en] Returns true when inner-generator doesn't exists
[jp] 稼働状態を返す。 falseの際はstepを実行しても進まない pause/resumeなどで更新
[en] Return isAwake
Adds RunnerAction
const runner = new Runner();
// Sample action (this: Runner)
const gotoAction = function* (x, duration) {
let count = 0;
const progressUnit = (x - this.target.x) / duration;
while (count < duration) {
this.target.x += progressUnit;
yield count++;
}
};
// 1. simple pattern
runner.addAction(gotoAction, 200, 120);
// 2. createAction pattern
function createGotoAction(x, duration) {
return function() {
return gotoAction.bind(this)(x, duration)
}
}
// alternative: 直接引数を埋め込んだRunnerActionを返す
function createGotoActionDirect(x, duration) {
return function*() {
let count = 0;
const progressUnit = (x - this.target.x) / duration;
while (count < duration) {
this.target.x += progressUnit;
yield count++;
}
}
}
runner.addAction(createGotoAction(200, 120));
runner.addAction(createGotoActionDirect(200, 120));
// 3. Set with iife
runner.addAction(
(()=> {
const x = 200;
const duration = 120;
return function*() {
let count = 0;
const progressUnit = (x - this.target.x) / duration;
while (count < duration) {
this.target.x += progressUnit;
yield count++;
}
}
})()
);
GeneratorFunctionでthisをRunnerにしたもの、文字列指定で予め登録したAction実行可能?
Rest
...args: any可変長でRunnerAction実行時の引数パラメータを設定(文字列指定で有効、それ以外は使いずらいかも?)
(WIP, maybe removed)
[en] Add action with pre-registered action name
[jp] 予め登録したアクション名でアクションを追加
import {ActionDictionary,BaseRunner} from "pgul"
ActionDictionary.register("goto", function* (x, duration) {
let count = 0;
const progressUnit = (x - this.target.x) / duration;
while (count < duration) {
this.target.x += progressUnit;
yield count++;
}
});
// Load action
const runner = new BaseRunner<any, "goto">();
runner.addActionByName("goto", 200, 120);
Rest
...args: anyargs for runnerAction
[jp] タスクを追加
[en] Add coroutine task
this
func<*function>とarguments<any[]>をもったオブジェクト
追加後に内部Generatorをリセットするかどうか
[jp] JSONでタスク設定
[en] addTaskFromJSON
this
[jp] 内部Generatorをクリア(コルーチン処理消去)
[en] Clear current running generator.
this
[jp] 処理をポーズする(step処理をスキップするようにする)
[en] Pause coroutine stepping.
this
[jp] taskリストからジェネレーターをリセット
[en] Reset
this
[jp] ポーズ中の処理を再開
[en] Resume coroutine stepping.
this
[jp] ループを設定
[en] Whether to reset generator after it is "done".
this
[jp] step可能にする 内部ジェネレーターリセットも兼ねる
[en] Reset and enable coroutine stepping
this
Static
convert[jp] taskリストをジェネレーターオブジェクトに変換
[en] convertTaskListToGenarator
Converted Generator
task.actionのthisとして扱うオブジェクト
Generated using TypeDoc
BaseRunner Corutionの機能を使って対象物のパラメータを変化させるためのクラス