@urso/core 0.8.22 → 0.8.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,9 @@ require('./app/config/load'); // your game application
17
17
 
18
18
  window.onload = Urso.runGame; //run game
19
19
  ```
20
+
20
21
  ### Table of Contents ###
22
+
21
23
  1. Getting Started
22
24
  2. Project Structure
23
25
  3. Engine Architecture and Launch Process
@@ -38,10 +40,10 @@ window.onload = Urso.runGame; //run game
38
40
  18. Game Text Localization
39
41
  19. Transport
40
42
  20. Additional Reference Sections
41
- 20.1. Core Modules (Lib)
42
- 20.2. Additional Information about Templates and Scenes
43
- 20.3. Practical Recommendations, Debugging, Profiling
44
- 20.4. Examples and API Reference (Compatible Elements)
43
+ - 20.1. Core Modules (Lib)
44
+ - 20.2. Additional Information about Templates and Scenes
45
+ - 20.3. Practical Recommendations, Debugging, Profiling
46
+ - 20.4. Examples and API Reference (Compatible Elements)
45
47
  21. Extra (BrowserEvents, PixiPatch)
46
48
  22. Types (Urso.types)
47
49
  23. Events (Urso.events)
@@ -54,7 +56,9 @@ window.onload = Urso.runGame; //run game
54
56
  30. Code Examples
55
57
  31. Links
56
58
 
57
- 1. Getting Started
59
+ ------------------
60
+
61
+ ### 1. Getting Started ###
58
62
  ------------------
59
63
  After cloning the repository locally, you need to install all game dependencies before launching.
60
64
 
@@ -66,7 +70,7 @@ After installing dependencies, to launch the game you need to execute:
66
70
  - yarn start
67
71
  - npm run start
68
72
 
69
- 2. Project Structure
73
+ ### 2. Project Structure ###
70
74
  --------------------
71
75
  Game source code and resources are located in:
72
76
  - src/app — source code (application)
@@ -77,7 +81,7 @@ Each game must include:
77
81
  - src/app/config/main.js — setting important game parameters (name, default scene).
78
82
  - src/js/index.js — application entry point. Engine code is connected through dependencies, load.js and main.js of the game. Once all engine files are loaded, you need to launch the application using Urso.runGame() function (usually on window.onload).
79
83
 
80
- 3. Engine Architecture and Launch Process
84
+ ### 3. Engine Architecture and Launch Process ###
81
85
  ------------------------------------------
82
86
  The game depends on Core by default.
83
87
 
@@ -97,7 +101,7 @@ Urso.config.extendingChain = ['Urso.Core', 'Urso.App'];
97
101
 
98
102
  Urso.runGame method in turn will begin loading the default scene using the scene manager.
99
103
 
100
- 4. Objects Required for Game Launch
104
+ ### 4. Objects Required for Game Launch ###
101
105
  ------------------------------------
102
106
  - Urso.helper — contains a set of helper methods for developer convenience (see src/js/lib/helper.js in Core repository).
103
107
  - Urso.observer — provides event-driven model operation (see src/js/modules/observer in Core repository).
@@ -114,7 +118,7 @@ Urso.runGame method in turn will begin loading the default scene using the scene
114
118
  - Urso.template — templating engine that provides work with templates (see src/js/modules/template in Core repository).
115
119
  - Urso.browserEvents — browser event translator to game (see src/js/extra/browserEvents.js in Core repository).
116
120
 
117
- 5. Scenes, Scene Sizes, Templates, Components and Simple Objects
121
+ ### 5. Scenes, Scene Sizes, Templates, Components and Simple Objects ###
118
122
  ----------------------------------------------------------------
119
123
  Scene — a set of objects that are present on screen and display some specific game state (main menu, loading screen, game level).
120
124
 
@@ -149,7 +153,7 @@ General best practices for components
149
153
  - Local subscriptions
150
154
  - Selectors for searching inside component through this.common.find/One/All
151
155
 
152
- 6. Component Connection and Organization
156
+ ### 6. Component Connection and Organization ###
153
157
  ----------------------------------------
154
158
  To add a component, in src/app/config/load.js you need to specify the path to component name and in the component folder specify all files that need to be loaded into the game.
155
159
 
@@ -173,14 +177,14 @@ Urso.localData — object (cache) where you can write and get parameters for fur
173
177
  - Urso.localData.set(key, value) — parameter writing.
174
178
  - Urso.localData.get(name) — value getting.
175
179
 
176
- 7. Object Visibility Order (Layers)
180
+ ### 7. Object Visibility Order (Layers) ###
177
181
  ------------------------------------
178
182
  All objects have their visibility order — layer on scene. Each object can be behind or in front of another object.
179
183
 
180
184
  Order is implemented as follows:
181
185
  - Top object specified in code (in object list, for example on scene) will be behind the object specified below it in the list — i.e., in the background.
182
186
 
183
- 8. Working with Scene Objects (Search, Selectors)
187
+ ### 8. Working with Scene Objects (Search, Selectors) ###
184
188
  --------------------------------------------------
185
189
  Tools for working with scene objects (and from console):
186
190
  - this.common.find — returns false/object/collection (Urso.find('selector') for console access).
@@ -202,7 +206,7 @@ Selector — combination of modifier and searched name. Example: '.logo' will se
202
206
  Combined selectors:
203
207
  - Urso.find('^nameContainer .classText') — search in '^nameContainer' object for objects with 'classText' class at any nesting level.
204
208
 
205
- 9. Event Routers and Event-Driven Model (Observer)
209
+ ### 9. Event Routers and Event-Driven Model (Observer) ###
206
210
  ---------------------------------------------------
207
211
  Event routers, using Urso.observer, control the state of entire game and individual components.
208
212
 
@@ -232,7 +236,7 @@ Console access:
232
236
  - Urso.observer.remove — analog of this.removeListener.
233
237
  - Urso.observer.fire — analog of this.emit.
234
238
 
235
- 10. Dynamic Scene Object Creation
239
+ ### 10. Dynamic Scene Object Creation ###
236
240
  ----------------------------------
237
241
  Objects can be created dynamically (for example, in components).
238
242
 
@@ -248,7 +252,7 @@ Urso.objects.create(
248
252
  someParentObject
249
253
  );
250
254
 
251
- 11. Working with Classes and Entities
255
+ ### 11. Working with Classes and Entities ###
252
256
  -------------------------------------
253
257
  Class access:
254
258
  - this.getInstance('View') — returns object (instance) of View class of the same namespace. That is, for Components.Test.Controller returns object of Components.Test.View class.
@@ -262,7 +266,7 @@ These methods accept parameter — path to needed class. Example:
262
266
  Internal calls:
263
267
  - In any class you can call this.getInstance('Template') to get Template instance of the same entity.
264
268
 
265
- 12. Adding Sound and Sound/Event Mapping Configuration
269
+ ### 12. Adding Sound and Sound/Event Mapping Configuration ###
266
270
  -------------------------------------------------------
267
271
  Sounds can be added for any game events: background music, button click sound, etc. Sounds are used as assets added to asset group.
268
272
 
@@ -296,7 +300,7 @@ Example:
296
300
  { soundKey: 'sound_check', event: 'soundCheck.resume', action: 'resume' },
297
301
  { soundKey: 'sound_check', event: 'soundCheck.play.loop', action: 'play', relaunch: true, loop: true }
298
302
 
299
- 13. LazyLoad Mechanism (Asset Loading Groups)
303
+ ### 13. LazyLoad Mechanism (Asset Loading Groups) ###
300
304
  ----------------------------------------------
301
305
  Urso.assets — resource loading logic (see src/js/modules/assets in Core repository).
302
306
 
@@ -312,7 +316,7 @@ Prioritization:
312
316
  - Group queue corresponds to order in lazyLoadGroups array (see src/js/modules/assets/config in Core repository).
313
317
  - Example: loadingGroup: "lazy" and "afterLazy"; in config this.loadingGroups = { initial: 0, lazy: "lazy", afterLazy: "afterLazy" }, and this.lazyLoadGroups = [ this.loadingGroups.lazy, this.loadingGroups.afterLazy ] — priority "lazy", then "afterLazy".
314
318
 
315
- 14. States Manager and Components.StateDriven
319
+ ### 14. States Manager and Components.StateDriven ###
316
320
  ----------------------------------------------
317
321
  States manager — connection of logical module (Modules.States) controlling active states and their actions, and components inherited from base state-dependent component (Components.StateDriven).
318
322
 
@@ -373,7 +377,7 @@ configActions = {
373
377
  - After closing — transition nextState: ['WAIT'].
374
378
  - In component controller state entry check (SHOW_MENU) through configStates; in configActions — open/close logic.
375
379
 
376
- 15. LayersSwitcher Component
380
+ ### 15. LayersSwitcher Component ###
377
381
  ----------------------------
378
382
  Component for enabling and disabling layers in game (see urso\core\src\js\components\layersSwitcher).
379
383
 
@@ -397,7 +401,7 @@ this.groupsLayers example:
397
401
  'background': ['.background'],
398
402
  }
399
403
 
400
- 16. Modifications and Mixins
404
+ ### 16. Modifications and Mixins ###
401
405
  -----------------------------
402
406
  Modifications — code files executed instead of standard ones under certain condition.
403
407
 
@@ -415,7 +419,7 @@ mixins: { Desktop: { Controller: require('./mixins/desktop/controller.js') } }
415
419
 
416
420
  If Urso.getInstancesModes() contains Desktop — method from mixin ('./mixins/desktop/controller.js') will execute in component Controller.
417
421
 
418
- 17. Transitions for Objects
422
+ ### 17. Transitions for Objects ###
419
423
  ----------------------------
420
424
  Transition — smooth transformation (see src\js\modules\objects\baseModel.js in Core repository).
421
425
 
@@ -434,7 +438,7 @@ Changing:
434
438
  - object.x = 200; object.y = 300 (diagonal movement).
435
439
  You can set one coordinate for axis movement.
436
440
 
437
- 18. Game Text Localization
441
+ ### 18. Game Text Localization ###
438
442
  ---------------------------
439
443
  Text translation to different languages is performed through JSON localization files for each language. Structure: translation key — text.
440
444
 
@@ -458,7 +462,7 @@ Usage:
458
462
  - Use localeId instead of text in text objects
459
463
  - Listen to language change event (Urso.events.MODULES_I18N_NEW_LOCALE_WAS_SET) and update texts
460
464
 
461
- 19. Transport
465
+ ### 19. Transport ###
462
466
  -------------
463
467
  19.1. Connection Type Support
464
468
  - websocket, xhr (by configuration)
@@ -473,7 +477,7 @@ Usage:
473
477
  19.3. ModulesTransportDecorator Decorator
474
478
  - toServer/toFront
475
479
 
476
- 20. Additional Reference Sections
480
+ ### 20. Additional Reference Sections ###
477
481
 
478
482
  20.1. Core Modules (Lib)
479
483
  - helper — utilities (for example, parseGetParams, waitForDomElement, arraysGetUniqElements, replaceAll, recursiveGet, mergeObjectsRecursive).
@@ -494,7 +498,7 @@ Usage:
494
498
  - For sound consider tab visibility rules (browser event handling).
495
499
  - Debug component — for FPS/metrics monitoring
496
500
 
497
- 21. Extra (BrowserEvents, PixiPatch)
501
+ ### 21. Extra (BrowserEvents, PixiPatch) ###
498
502
  ------------------------------------
499
503
  21.1. BrowserEvents
500
504
  - Browser event translation (resize, visibilitychange, input) to engine events: EXTRA_BROWSEREVENTS_*
@@ -503,7 +507,7 @@ Usage:
503
507
  21.2. PixiPatch
504
508
  - PIXI fixes/extensions
505
509
 
506
- 22. Types (Urso.types)
510
+ ### 22. Types (Urso.types) ###
507
511
  ----------------------
508
512
  22.1. assets
509
513
  - ATLAS, AUDIOSPRITE, BITMAPFONT, CONTAINER, FONT, IMAGE, JSON, JSONATLAS, SOUND, SPINE, HTML
@@ -539,7 +543,7 @@ Specialized objects
539
543
  - Screen orientations: Urso.device.ScreenOrientation.LANDSCAPE/ PORTRAIT
540
544
  - Engine constants
541
545
 
542
- 23. Events (Urso.events)
546
+ ### 23. Events (Urso.events) ###
543
547
  ------------------------
544
548
  23.1. System Event Examples
545
549
  - MODULES_SCENES_NEW_SCENE_INIT
@@ -550,7 +554,7 @@ Specialized objects
550
554
  - module.domain.action
551
555
  - ui.*, game.*, sound.*, scenes.*, assets.*, transport.*
552
556
 
553
- 24. Practical Patterns and Recommendations
557
+ ### 24. Practical Patterns and Recommendations ###
554
558
  -------------------------------------------
555
559
  24.1. Abstraction Layers
556
560
  - Logic — in services/routers
@@ -583,7 +587,7 @@ Specialized objects
583
587
  - Break complex states into all/race/sequence combinations
584
588
  - Use terminateEvents for graceful parallel Action stopping
585
589
 
586
- 25. Optimization and Debugging
590
+ ### 25. Optimization and Debugging ###
587
591
  -------------------------------
588
592
  25.1. Debug Component
589
593
  - FPS display, draw calls, object count
@@ -601,7 +605,7 @@ Specialized objects
601
605
  25.4. Build
602
606
  - Debug build:dev; minimize build:prod
603
607
 
604
- 26. FAQ
608
+ ### 26. FAQ ###
605
609
  -------
606
610
  - How to launch game? — see Quick Start: index.js + load.js + runGame
607
611
  - Where to connect modules? — config/load.js
@@ -610,7 +614,7 @@ Specialized objects
610
614
  - How to find object? — this.common.find/One/All or Urso.find*/ selectors ^ . #
611
615
  - How to configure asset quality? — through Urso.assets.updateQuality/ setQuality and qualityFactors config
612
616
 
613
- 27. Examples from A to Z
617
+ ### 27. Examples from A to Z ###
614
618
  ------------------------
615
619
  27.1. Mini-menu + game transition
616
620
  - main.js: defaultScene = 'menu'
@@ -643,7 +647,7 @@ emit('fullscreen.toggle')
643
647
  27.9. Debug
644
648
  Add Debug component to scene for monitoring
645
649
 
646
- 28. API Reference
650
+ ### 28. API Reference ###
647
651
  -----------------
648
652
  28.1. Core/Global
649
653
  - Urso.runGame()
@@ -681,7 +685,7 @@ Add Debug component to scene for monitoring
681
685
  28.8. Logger
682
686
  - error/warning/info/log; levels through defaultLogLevel
683
687
 
684
- 29. Appendices
688
+ ### 29. Appendices ###
685
689
  --------------
686
690
  29.1. Naming Conventions
687
691
  - Event names: domain.action.detail (for example, sound.play.click, ui.button.play.click)
@@ -695,7 +699,7 @@ Add Debug component to scene for monitoring
695
699
  - Logs and levels reduced for production
696
700
  - Performance on target devices measured
697
701
 
698
- 30. Code Examples
702
+ ### 30. Code Examples ###
699
703
  -----------------
700
704
  index.js
701
705
 
@@ -760,7 +764,7 @@ window.Urso.App = {
760
764
 
761
765
  require('./main.js');
762
766
 
763
- 31. Links
767
+ ### 31. Links ###
764
768
  ---------
765
769
  - https://ursojs.io/examples.html
766
770
  - https://github.com/megbrimef/urso-examples