Skip to content

Commit 7c50049

Browse files
Updates readme file.
1 parent 22da00c commit 7c50049

File tree

12 files changed

+390
-152
lines changed

12 files changed

+390
-152
lines changed

CHANGELOG.MD

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
## dev
1+
## v1.0.1 - Jan 8, 2023
22

3-
* The new random configurations are used by the EmitRandomTickActionScript and DelayRandomActionScript:
4-
- RandomMultipleComp
5-
- RandomInArrayComp
6-
- RandomBetweenComp
3+
First version.

README.MD

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Phaser Editor 2D Timer Scripts (library)
1+
# Phaser Editor 2D Random Scripts (library)
22

3-
This project contains Phaser Editor 2D scripts for using a timer.
3+
This project contains Phaser Editor 2D scripts for configuring random actions.
44

55
These script nodes are very basic and may fit on any Phaser Editor 2D project.
66

@@ -16,7 +16,7 @@ To install this in your game you have to install dependencies too:
1616

1717
```
1818
npm install @phasereditor2d/scripts-core
19-
npm install @phasereditor2d/scripts-timer
19+
npm install @phasereditor2d/scripts-random
2020
```
2121

2222
Also, you should add this package to the `phasereditor2d.config.json` file in your project, in the `scripts` section:
@@ -25,53 +25,57 @@ Also, you should add this package to the `phasereditor2d.config.json` file in yo
2525
{
2626
"scripts": [
2727
"@phasereditor2d/scripts-core",
28-
"@phasereditor2d/scripts-timer"
28+
"@phasereditor2d/scripts-random"
2929
]
3030
}
3131
```
3232

3333
## Installing (vanilla JavaScript)
3434

3535
* Get the files in the [browser](./browser/) folder and copy them into your JavaScript project. It includes Phaser Editor 2D files, JavaScript files, and TypeScript type definitions.
36-
* Add a `script` tag to the `index.html` file to load the `lib/phasereditor2d_scripts_timer.js` file.
36+
* Add a `script` tag to the `index.html` file to load the `lib/phasereditor2d_scripts_random.js` file.
3737

3838
## Summary
3939

40-
This library provides a few actions for implementing timers in your game.
40+
This library provides a few actions for using random values in your game. You can configure the domain of the random values by using the configuration components.
4141

4242
As a reminder, an action is executed by an event script or another action.
4343

4444
The actions:
4545

46-
* **Delay Action** - Delays, then executes the children's scripts.
47-
* **Delay Random Action** - Delays a random time, then executes the children's
48-
* **Emit Tick Action** - Emits a tick at every given delay.
49-
* **Emit Random Tick Action** - Emits a tick always at a random delay.
46+
* **Set Random X Action** - Set a random value to the object's X.
47+
* **Set Random Y Action** - Set a random value to the object's X.
5048

51-
## Delay Action
49+
The configuration components:
5250

53-
*Class: DelayActionScript*
51+
* **Random Between Config** - To select an integer random value between two numbers.
52+
* **Random Multiple Config** - To select an integer random multiple between two numbers.
53+
* **Random In Array Config** - To pick a random value in an array of options.
5454

55-
This action delays a given **Delay** time and then executes the children's scripts.
55+
## Set Random X Action
5656

57-
## Delay Random Action
57+
*Class: SetRandomXActionScript*
5858

59-
*Class: DelayRandomActionScript*
59+
This action sets a random X value to the game object. It requires that you add to this node one of the random configuration components.
6060

61-
This action delays a random time and then executes the children's scripts.
61+
It allows
6262

63-
The delay time is a random number between the given **Min** and **Max** parameters.
63+
## Set Random Y Action
6464

65-
## Emit Tick Action Script
65+
*Class: SetRandomYActionScript*
6666

67-
*Class: EmitTickActionScript*
67+
This action sets a random Y value to the game object. It requires that you add to this node one of the random configuration components.
6868

69-
This action emits a tick at a fixed rate, within the given **Delay**. At every tick, it executes the children's scripts.
69+
## Random Between Config
7070

71-
## Emit Random Tick Action
71+
This user component contains the configuration for generating a random integer values between the given parameters **Min** and **Max**.
7272

73-
*Class: EmitRandomTickActionScript*
73+
## Random Multiple Config
7474

75-
This action emits a tick at a random rate. At every tick, it executes the children's scripts.
75+
This user component contains the configuration for generating random integer values between the given parameters **Min** and **Max**, but it is also a multiple of the **Multiple** parameter.
7676

77-
The delay time is a random number between the given **Min** and **Max** parameters.
77+
Eg., with a multiple of 10, the possible values between 10 and 30 are 10, 20, and 30.
78+
79+
## Random In Array Config
80+
81+
This user component contains the parameters for picking a random number from an array of options. You can write the array in the **Options** parameters, following a JSON array format. Like this: `[10, 34, 2, 89, 20]`.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"components": [
3+
{
4+
"name": "RandomMultipleComp",
5+
"displayName": "Random Multiple Config",
6+
"objectDisplayFormat": "a multiple of \"${multiple}\" between \"${min}\" to \"${max}\"",
7+
"baseClass": "",
8+
"gameObjectType": "any",
9+
"properties": [
10+
{
11+
"name": "multiple",
12+
"label": "Multiple",
13+
"tooltip": "Select a random multiple in a range.",
14+
"defValue": 10,
15+
"customDefinition": false,
16+
"type": {
17+
"id": "number"
18+
}
19+
},
20+
{
21+
"name": "min",
22+
"label": "Min",
23+
"tooltip": "Min random number.",
24+
"defValue": 0,
25+
"customDefinition": false,
26+
"type": {
27+
"id": "number"
28+
}
29+
},
30+
{
31+
"name": "max",
32+
"label": "Max",
33+
"tooltip": "Max random number.",
34+
"defValue": 1000,
35+
"customDefinition": false,
36+
"type": {
37+
"id": "number"
38+
}
39+
}
40+
]
41+
},
42+
{
43+
"name": "RandomInArrayComp",
44+
"displayName": "Random In Array Config",
45+
"objectDisplayFormat": "one in \"${options}\"",
46+
"baseClass": "",
47+
"gameObjectType": "any",
48+
"properties": [
49+
{
50+
"name": "options",
51+
"label": "Options",
52+
"tooltip": "",
53+
"defValue": "[]",
54+
"customDefinition": false,
55+
"type": {
56+
"id": "expression",
57+
"expressionType": "number[]"
58+
}
59+
}
60+
]
61+
},
62+
{
63+
"name": "RandomBetweenComp",
64+
"displayName": "Random Number Between Config",
65+
"objectDisplayFormat": "between \"${min}\" and \"${max}\"",
66+
"baseClass": "",
67+
"gameObjectType": "any",
68+
"properties": [
69+
{
70+
"name": "min",
71+
"label": "Min",
72+
"tooltip": "",
73+
"defValue": 0,
74+
"customDefinition": false,
75+
"type": {
76+
"id": "number"
77+
}
78+
},
79+
{
80+
"name": "max",
81+
"label": "Max",
82+
"tooltip": "",
83+
"defValue": 1000,
84+
"customDefinition": false,
85+
"type": {
86+
"id": "number"
87+
}
88+
}
89+
]
90+
}
91+
],
92+
"meta": {
93+
"app": "Phaser Editor 2D - User Components Editor",
94+
"url": "https://phasereditor2d.com",
95+
"contentType": "phasereditor2d.core.scene.UserComponents"
96+
},
97+
"outputLang": "TYPE_SCRIPT",
98+
"exportClass": true,
99+
"autoImport": true
100+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"id": "f3e45584-d862-41d7-8c1d-2773f3bd26e1",
3+
"sceneType": "PREFAB",
4+
"settings": {
5+
"exportClass": true,
6+
"autoImport": true,
7+
"prefabObjDisplayFmt": "Set random X",
8+
"displayName": "Set Random X Action",
9+
"preloadMethodName": "",
10+
"preloadPackFiles": [],
11+
"createMethodName": "",
12+
"compilerOutputLanguage": "TYPE_SCRIPT",
13+
"borderWidth": 360,
14+
"borderHeight": 240
15+
},
16+
"displayList": [
17+
{
18+
"type": "ScriptNode",
19+
"id": "cfa82599-d5ba-4524-8032-ee194a32f991",
20+
"label": "scriptnode_1"
21+
}
22+
],
23+
"plainObjects": [],
24+
"meta": {
25+
"app": "Phaser Editor 2D - Scene Editor",
26+
"url": "https://phasereditor2d.com",
27+
"contentType": "phasereditor2d.core.scene.SceneContentType",
28+
"version": 5
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"id": "5a91c1a7-7a9c-4134-84ff-66d251330ad2",
3+
"sceneType": "PREFAB",
4+
"settings": {
5+
"exportClass": true,
6+
"autoImport": true,
7+
"prefabObjDisplayFmt": "Set random Y",
8+
"displayName": "Set Random Y Action",
9+
"preloadMethodName": "",
10+
"preloadPackFiles": [],
11+
"createMethodName": "",
12+
"compilerOutputLanguage": "TYPE_SCRIPT",
13+
"borderWidth": 360,
14+
"borderHeight": 240
15+
},
16+
"displayList": [
17+
{
18+
"type": "ScriptNode",
19+
"id": "46c88e69-18e0-4a17-8804-81988e99b5e7",
20+
"label": "scriptnode_1"
21+
}
22+
],
23+
"plainObjects": [],
24+
"meta": {
25+
"app": "Phaser Editor 2D - Scene Editor",
26+
"url": "https://phasereditor2d.com",
27+
"contentType": "phasereditor2d.core.scene.SceneContentType",
28+
"version": 5
29+
}
30+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
declare class GetRandom {
2+
static getRandom(node: ScriptNode): number;
3+
}
4+
5+
declare class RandomBetweenComp {
6+
constructor(gameObject: any);
7+
static getComponent(gameObject: any): RandomBetweenComp;
8+
private gameObject;
9+
min: number;
10+
max: number;
11+
getRandomBetween(): number;
12+
}
13+
14+
declare class RandomInArrayComp {
15+
constructor(gameObject: any);
16+
static getComponent(gameObject: any): RandomInArrayComp;
17+
private gameObject;
18+
options: number[];
19+
getRandomInArray(): number;
20+
}
21+
22+
declare class RandomMultipleComp {
23+
constructor(gameObject: any);
24+
static getComponent(gameObject: any): RandomMultipleComp;
25+
private gameObject;
26+
multiple: number;
27+
min: number;
28+
max: number;
29+
private getRandomMultipleInRange;
30+
getRandomMultiple(): number;
31+
}
32+
33+
declare class SetRandomXActionScript extends ScriptNode {
34+
constructor(parent: ScriptNode | Phaser.GameObjects.GameObject | Phaser.Scene);
35+
execute(...args: any[]): void;
36+
}
37+
38+
declare class SetRandomYActionScript extends ScriptNode {
39+
constructor(parent: ScriptNode | Phaser.GameObjects.GameObject | Phaser.Scene);
40+
execute(...args: any[]): void;
41+
}
42+
43+

0 commit comments

Comments
 (0)