Help us understand the problem. What is going on with this article?

jsでシーン管理するライブラリつくったよ

More than 5 years have passed since last update.

================================
内容薄いですがとりあえず共有

元Flasherには馴染みのある、シーン管理の概念をjavascriptに導入する。
まだ低機能ですが、既にHTMLコンテンツや他のJSゲーム系アプリで利用してます。

github
ソース

HTMLサンプル
※Chromeのみ確認済

機能

urlライクな"シーンパス"と、それに紐づく"シーン"の組み合わせと、遷移を管理する。

使い方

// "/"シーンの定義
Scene.add("/").set({
    onShow: function(){ console.log("/ 表示処理"); },
    onHide: function(){ console.log("/ 非表示処理"); }
});
// "/scene1"シーンの定義
Scene.add("/scene1").set({
    onEnter: function(){ console.log("/scene1以下に影響する処理"); },
});
// "/scene1/child"シーンの定義
Scene.add("/scene1/child").set({
    onShow: function(){ console.log("/scene1 表示処理"); },
    onHide: function(){ console.log("/scene1 非表示処理"); }
});

// "/"へ遷移
Scene.goto("/");

// 1秒後に"/scene1/child"へ遷移
setTimeout( function(){ Scene.goto("/scene1/child"); }, 1000 );

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした