layout for Phaser by YAML config file, only support mobile devices
- config layout
- auto scale
- easy
- js-yaml (parse YAML text)
- lodash (make js easy)
-
include library file js-yaml, lodash
-
load layout script
- UIConfig.js (parse config)
- UICreator.js (create Phaser object by UIConfig result)
- Shape.js (Phaser.Graphics wrapper)
-
load layout config file
// at previous game state this.game.load.text("MyScene", "assets/layout/MyScene.yaml");
-
inherit ConfigLayout e.g.
var MySceneControl = function () { ConfigLayout.call(this); } MySceneControl.prototype = _.create(ConfigLayout.prototype, { "constructor": MySceneControl, "_super": ConfigLayout.prototype, init: function () { // load a config file this.addLayoutFile("MyScene"); this._super.init(); }, preload: function () { this._super.preload(); }, create: function () { this._super.create(); // TODO: add control for display things }, });
-
get sprite refrence by name
create: function () { this._super.create(); // get background sprite by config name attr var bgSprite = this.get("bg"); // var bgSprite = this.get("背景"); // TODO: add control for display things },
- use ConfigLayout layout display object
- inherit ConfigLayout with control, animation ... (support function for service)
- inherit suggestion 2 with service implement
See HowToConfig.md