/* * constant */ var SCREEN_WIDTH = 640; var SCREEN_HEIGHT = 480; var SCREEN_CENTER_X = SCREEN_WIDTH/2; var SCREEN_CENTER_Y = SCREEN_HEIGHT/2; // アセット var ASSETS = { "bigChick": "neko.png" }; //画像読み込み tm.asset.AssetManager.load("TitleImage" , "title.png"); /* * メイン処理(ページ読み込み後に実行される) */ tm.main(function() { // アプリケーション作成 var app = tm.app.CanvasApp("#world"); app.resize(SCREEN_WIDTH, SCREEN_HEIGHT); // リサイズ app.fitWindow(); // 自動フィット app.replaceScene(TitleScene()); // 実行 app.run(); }); /** * TitleScene */ tm.define("TitleScene", { superClass : "tm.app.TitleScene", init : function() { this.superInit({ title : "タイトル画面", width : SCREEN_WIDTH, height : SCREEN_HEIGHT, backgroundImage : "TitleImage" }); }, update: function(app) { var key = app.keyboard; if (key.getKey("z")) { // シーンの遷移 var loadingScene = tm.app.LoadingScene({ assets: ASSETS, nextScene: MainScene, width: SCREEN_WIDTH, height: SCREEN_HEIGHT }); this.app.replaceScene(loadingScene); } } }); tm.define("MainScene", { superClass: "tm.app.Scene", init: function() { // 親の初期化 this.superInit(); this.star = tm.app.Sprite("bigChick"); this.addChild(this.star); // シーンに追加 }, update: function(app) { var p = app.pointing; // マウス位置 or タッチ位置に移動 this.star.x = p.x; this.star.y = p.y; // クリック or タッチ中は回転させる if (app.pointing.getPointing() == true) { this.star.rotation += 15; } var key = app.keyboard; if (key.getKey("z")) { this.star.scaleX += 0.1; } }, });