prefab-user-properties-expression-type.rst 737 B

1234567891011121314151617181920212223
  1. .. include:: ../_header.rst
  2. Expression property type
  3. ````````````````````````
  4. The Expression type is the way you have to create a property of any type. You can use any type for the values and any JavaScript expression for setting the values. For example, you can use it to create a property to reference an event handler (or callback function):
  5. .. image:: ../images/prefab-user-props-expression-param-06062020.webp
  6. :alt: Expression property declaration.
  7. The |SceneCompiler|_ generates Expression properties like this:
  8. .. code::
  9. class Dragon extends Phaser.GameObjects.Sprite {
  10. constructor(..) {
  11. ...
  12. }
  13. /** @type {(obj:Dragon)=>void} */
  14. onClickHandler = obj => {};
  15. }