|
1 |
| -# phaser-ui-comps |
2 |
| -Phaser 3 UI Components built by Adobe Animate |
| 1 | +Phaser 3 UI Components, built by Adobe Animate |
| 2 | +---- |
| 3 | +<h3>What is it?</h3> |
| 4 | +Build your UI in [Abode Animate](https://www.adobe.com/ru/products/animate.html), |
| 5 | +export to JSON and bitmaps with provided |
| 6 | +[JSFL script](https://github.com/xense/phaser-ui-comps/blob/master/jsfl/ExportToPhaser.jsfl) |
| 7 | +, and you can forget about lots of positioning magic numbers in your code. |
| 8 | + |
| 9 | +`ComponentClip` build itself with provided JSON and atlases, |
| 10 | +and `UIComponentPrototype` Will help to control them, switch states, |
| 11 | +listen to click, drag and other events. |
| 12 | + |
| 13 | +In addition, `UIComponentPrototype` and it"s children classes don"t mind, |
| 14 | +if they have a real clip instance in current state or at all, |
| 15 | +so nothing bad happens, for example, if you remove some button instance in your window in |
| 16 | +Animate document and keep it"s `UIComponentPrototype` instance. |
| 17 | + |
| 18 | +All bitmaps are exported to png files with the same folder structure |
| 19 | +as in the Animate document library. Pack them to atlases using |
| 20 | +[TexturePacker](https://www.codeandweb.com/texturepacker) or other tool you like. |
| 21 | + |
| 22 | +<h3>Where and how to use?</h3> |
| 23 | + |
| 24 | +[Main framework repo](https://github.com/xense/phaser-ui-comps) |
| 25 | + |
| 26 | +[Docs, tutorials, examples](https://xense.github.io/phaser-ui-comps-docs) |
| 27 | + |
| 28 | +[Live example](https://xense.github.io/phaser-ui-comps-docs/tutorial-showcase.html) |
| 29 | + |
| 30 | +[Issues, bugs, new components ideas](https://github.com/xense/phaser-ui-comps/issues) |
| 31 | + |
| 32 | +[Animate document example](https://github.com/xense/phaser-ui-comps-docs/tree/master/examples/xfl/) |
| 33 | + |
| 34 | +<h4>Export Animate document</h4> |
| 35 | +To run JSFL script in Animate select `Commands > Run Command`, |
| 36 | +navigate to the script, and click Open. |
| 37 | + |
| 38 | +<h3>How to install?</h3> |
| 39 | + |
| 40 | +To install the latest version from |
| 41 | +[npm](https://www.npmjs.com) |
| 42 | +locally and save it in your `package.json` file: |
| 43 | +```bash |
| 44 | +npm install --save phaser-ui-comps |
| 45 | +``` |
| 46 | + |
| 47 | +Or you can download minified version from |
| 48 | +[https://github.com/xense/phaser-ui-comps/tree/master/dist](https://github.com/xense/phaser-ui-comps/tree/master/dist) |
| 49 | + |
| 50 | +*Note!* |
| 51 | +*PhaserComps uses [underscore.js](https://underscorejs.org/) |
| 52 | +There are two builds in the /dist folder, |
| 53 | +[one](https://github.com/xense/phaser-ui-comps/blob/master/dist/phaser-ui-comps-with-underscore.min.js) |
| 54 | +with underscore included and |
| 55 | +[other](https://github.com/xense/phaser-ui-comps/blob/master/dist/phaser-ui-comps.min.js) |
| 56 | +without it, so you need to load it before loading PhaserComps* |
| 57 | + |
| 58 | +<h3>Simple usage</h3> |
| 59 | + |
| 60 | +```html |
| 61 | +<script src="path/to/scripts/phaser.js"></script> |
| 62 | +<script src="path/to/scripts/phaser-ui-comps-with-underscore.min.js"></script> |
| 63 | +``` |
| 64 | + |
| 65 | +```javascript |
| 66 | +const COMPONENT_CONFIG = "comp-config"; |
| 67 | +const TEXTURE_CONFIG = "my_texture"; |
| 68 | + |
| 69 | + |
| 70 | +var game = new Phaser.Game({ |
| 71 | + type: Phaser.AUTO, |
| 72 | + parent: "phaser-example", |
| 73 | + width: 800, |
| 74 | + height: 600, |
| 75 | + scene: { |
| 76 | + preload: preload, |
| 77 | + create: create |
| 78 | + } |
| 79 | +}); |
| 80 | + |
| 81 | + |
| 82 | +function preload() { |
| 83 | + this.load.json(COMPONENT_CONFIG, "assets/my_component.json"); |
| 84 | + this.load.multiatlas(TEXTURE_CONFIG, "assets/atlases/my_atlas.json", "assets/atlases/"); |
| 85 | +} |
| 86 | + |
| 87 | +function create() { |
| 88 | + let clip = new PhaserComps.ComponentClip( |
| 89 | + this, |
| 90 | + this.cache.json.get(COMPONENT_CONFIG), |
| 91 | + [ TEXTURE_CONFIG ] |
| 92 | + ); |
| 93 | + |
| 94 | + let component = new PhaserComps.UIComponents.UIComponentPrototype(); |
| 95 | + component.appendClip(clip); |
| 96 | +} |
| 97 | +``` |
0 commit comments