script-node-basic-scripts-project.rst 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. .. include:: ../_header.rst
  2. The Core scripts project
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~
  4. In the previous section, we covered how to create the ``ScriptNode`` class. It is very basic, it is the minimum you need for using the |ScriptNodes|_. For that reason, we created a project with other basic script nodes you can use in your game: the `scripts-core <http://github.com/PhaserEditor2D/phasereditor2d-scripts-core>`_ project.
  5. It is a project in development. In the way we get more experience making games with the script nodes, we may change it or increment the number of scripts on it.
  6. Following we present you a summary of the project. You can learn more on the project's site:
  7. `github.com/PhaserEditor2D/scripts-core <http://github.com/PhaserEditor2D/phasereditor2d-scripts-core>`_
  8. There are three groups of scripts: **Base**, **Events**, and **Actions**.
  9. Base scripts
  10. ''''''''''''
  11. Contains basic/abstract functionality. Often, you will create prefab variants of them (extend them).
  12. * **ScriptNode** - the base class for all the scripts.
  13. * **SpriteScriptNode** - base prefab for script nodes accessing sprite objects.
  14. * **RootScriptNode** - a script node that registers itself into the game object and can be used as a container of other scripts.
  15. Event scripts
  16. '''''''''''''
  17. These scripts listen to certain events. When the event is emitted, then executes the children, which are actions.
  18. * **OnEventScript** - registers to the given ``eventEmitter`` and listens to the given ``eventName`` event.
  19. * **OnSceneAwakeScript** - listens the ``scene-awake`` event of the scene.
  20. * **OnPointerDownScript** - listens to the ``pointerdown`` event of the game object.
  21. Action scripts
  22. ''''''''''''''
  23. Actions are scripts that are executed manually or by other nodes, like events or other actions. This is important, an action script doesn't execute by itself.
  24. * **CallbackActionScript** - executes the given ``callback`` expression.
  25. * **StartSceneActionScript** - starts the given ``sceneKey`` scene.
  26. * **ExecActionScript** - executes the given ``targetAction``.
  27. * **EmitEventActionScript** - the given ``eventEmitter`` emits the given ``eventName``.
  28. * **AlertActionScript** - shows the browser's alert dialog, with the given ``message``.
  29. * **ConsoleLogActionScript** - logs the given ``message`` to the browser's console.
  30. * **DestroyActionScript** - destroys the game object.