-
Notifications
You must be signed in to change notification settings - Fork 1
cuttlebone.Shell
Legokichi Duckscallion edited this page Apr 28, 2015
·
1 revision
コンストラクタです。
引数directoryのfilepathキーはdescript.txtがあるデリレクトリ直下のパスを指定してください。
var nar = new Nar();
nar.loadFromURL("./node_modules/ikagaka.nar.js/vender/mobilemaster.nar", function (err){
if(!!err) return console.error(err.stack);
if(nar.install["type"] === "ghost"){
var shellDir = nar.getDirectory(/shell\/master\//);
console.log(Object.keys(shellDir)); // => ["descript.txt", "surface0.png", "elements/element0.png", ..., "surfaces.txt"]
var shell = new Shell(shellDir);
}
});
descript.txtの中身をキーバリュー形式で持っています。
console.log(shell.descript["name"]); // -> 'the "MobileMaster"'
descript.txtやsurfaces.txt、surface*.png、surface*.pnaファイルを読み込みます。
shell.load().then(function(){
console.log(shell);
});
Shell#attatchSurface(canvas: HTMLCanvasElement, scopeId: number, surfaceId: string): SurfaceObject|null
指定したcanvasへscopeIdのsurfaceIdのサーフェスの描画を行います。 サーフェスIDはサーフェスエイリアスが考慮されます。 該当するサーフェスが存在しなかった場合、nullが返ります。
var canvas = document.createElement("canvas");
var surface = shell.attachSurface(canvas, 0, "0"); // \0\s[0]
document.body.appendChild(canvas);
canvasへのサーフェスの描画を止めて、canvasへのあらゆるイベントハンドラを解除します。 サーフェスを変更する前に必ず呼び出してください。
サーフェスを再描画します。
animationIdのアニメーションを再生します。 再生後にcallbackが呼ばれます。
animationIdのアニメーションを停止します。
animationIdの着せ替えを着せます。
animationIdの着せ替えを脱がせます。
yen-eタイミングのアニメーションを再生します。
talkタイミングのカウンタを進め、指定回数呼び出されるとtalkタイミングのアニメーションを再生します。