{"id":22826984,"url":"https://github.com/phasereditor2d/script-nodes-basic","last_synced_at":"2025-03-31T00:42:45.407Z","repository":{"id":157041482,"uuid":"616745954","full_name":"PhaserEditor2D/script-nodes-basic","owner":"PhaserEditor2D","description":"Basic Script Nodes may fit in any project.","archived":false,"fork":false,"pushed_at":"2023-12-06T03:10:38.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-06T06:16:53.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PhaserEditor2D.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-21T01:54:34.000Z","updated_at":"2023-04-12T13:27:53.000Z","dependencies_parsed_at":"2023-12-06T04:24:28.133Z","dependency_job_id":"41bae3de-4f8e-440f-8ae8-5634dcf1d441","html_url":"https://github.com/PhaserEditor2D/script-nodes-basic","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fscript-nodes-basic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fscript-nodes-basic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fscript-nodes-basic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fscript-nodes-basic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PhaserEditor2D","download_url":"https://codeload.github.com/PhaserEditor2D/script-nodes-basic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246399790,"owners_count":20770907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-12T18:07:24.191Z","updated_at":"2025-03-31T00:42:45.387Z","avatar_url":"https://github.com/PhaserEditor2D.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Basic Phaser Editor 2D script nodes\n\n**This project is deprecated. Check [phasereditor2d-scripts-core](./phasereditor2d-scripts-core)**\n\nThis project contains a couple of Script Nodes for Phaser Editor 2D.\n\nThese script nodes are very basic and may fit on any Phaser Editor 2D project.\n\nThe scripts are coded in TypeScript with ES modules.\n\n## Installing\n\nCopy this project folder (or clone the repo) and paste it into your project's `src/` folder.\n\n## Summary\n\nThere are three groups of scripts: **Base**, **Triggers**, and **Actions**.\n\n### Base scripts\n\nContain basic/abstract functionallity. Often, you will create prefab variants of them (extend them).\n\n* **ScriptNode** - the base class for all the scripts.\n* **SpriteScriptNode** - base prefab for script nodes accessing sprite objects.\n* **RootScriptNode** - a script node that registers itself into the game object and can be used as container of other scripts.\n\n### Trigger scripts\n\nThese scripts listen certain event. When the event is triggered, then execute the children, which are actions.\n\n* **OnEventScript** - registers to the given `eventEmitter` and listens the given `eventName` event.\n* **OnPointerDownScript** - listens the `pointerdown` event of the game object.\n\n### Action scripts\n\nActions are script that are executed manually or by other nodes, like triggers or other actions.\n\n* **CallbackActionScript** - executes the given `callback` expression.\n* **StartSceneActionScript** - starts the given `sceneKey` scene.\n* **ExecActionScript** - executes the given `targetAction`.\n* **EmitEventActionScript** - the given `eventEmitter` emits the given `eventName`.\n\n## ScriptNode\n\nThe base of all the scripts. Probably it is already avaliable in your project (if you generated it with Phaser Editor 2D).\n\nThis class provides methods for managing the node's children, and implementing the scene events: `awake`, `start`, and `update`.\n\n## SpriteScriptNode\n\nA base script for all the scripts accesing sprite objects. It just overrides the `gameObject` property and set its type to `Phaser.GameObjects.Sprite`. This helps IDE auto-completion and type-checking.\n\n## RootScriptNode\n\nA base script that you can use to register the script node into the game object. In this way you can access the scripts associated to a game object.\n\nWhen you create a **RootScriptNode**, it registers itself to the game object in this way:\n\n```\ngameObject[\"RootScript__scripts\"] = this;\n```\n\nYou can use the `key` parameter to register the root script node using other attribute. If the `key` parameter is `\"anotherScripts\"`, then it register the root node like this:\n\n```\ngameObject[\"RootScript__anotherScripts\"] = this;\n```\n\nThe **RootScriptNode** class contains utility methods for accessing the root script of a game object.\n\nThe static `getRoot()` method can be used for getting the root script:\n\n```\nconst script = RootScriptNode.getRoot(someGameObject);\nconst otherScript = RootScriptNode.getRoot(someGameObject, \"anotherScripts\");\n```\n\nThe static `hasRoot()` method tells if the game object as a root script:\n\n```\nif (RootScriptNode.hasRoot(gameObject, \"myScripts\")) {\n    ....\n}\n```\n\nThe static `getChildren()` method returns the chidlren of the root script:\n\n```\nconst children = RootScriptNode.getChildren(gameObject, \"myScripts\");\n```\n\nYou can create variants of the **RootScriptNode** and use different keys.\n\n## OnEventScript\n\nA trigger-like script node. It registers to the given `eventEmitter` and listens the given `eventName`. When the event is fired, it executes the children action nodes. \n\nYou can create handy prefab variants for different events, like the `OnPointerDownScript` prefab.\n\nYou can select an `eventEmitter` from the following list:\n\n* `game.events`\n* `scene.events`\n* `scene.loader`\n* `scene.input`\n* `scene.input.keyboard`\n* `scene.anims`\n* `gameObject` (by default)\n\n## OnPointerDownScript\n\nA trigger-like script. It is a prefab variant of the `OnEventScript` node. It listens to the `pointerdown` event of the game object, and executes the children action nodes.\n\nIf the game object's input is not set whe the scene \"awakes\", then this script calls the `gameObject.setInteractive()` method.\n\n## CallbackActionScript\n\nAn action-like script. It executes the given `callback` expression. You can use this script for executing custom methods from your prefabs or scenes.\n\n## StartSceneActionScript\n\nAn action-like script. It starts the given `sceneKey` scene.\n\n## ExecActionScript\n\nAn action-like script. It executes the given `targetAction`. You can use this script for executing an action node from script-tree.\n\nFor example, let's say you have a **JumpAction** for jumping a character. But you want to call this action when different events are fired:\n\n- When you click a jump button.\n- When you press the `SPACE` key.\n- When you press the `UP` button of an external gamepad.\n\nSo, you can use different **ExecActionScript** nodes in different contexts, but referencing the same **JumpAction** node.\n\n## EmitEventActionScript\n\nAn action like script. It calls the emit method of the given `eventEmitter` with the given `eventName`. As argument of the event it uses the argument received in the `execute()` method.\n\nLike in the **OnEventScript**, you can select an `eventEmitter` from a list:\n\n* `game.events`\n* `scene.events`\n* `scene.loader`\n* `scene.input`\n* `scene.input.keyboard`\n* `scene.anims`\n* `gameObject` (by default)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasereditor2d%2Fscript-nodes-basic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphasereditor2d%2Fscript-nodes-basic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasereditor2d%2Fscript-nodes-basic/lists"}