Abstract Class: LabelAbstract<TLabel, TProps, StepIdType>
Defined in: src/narration/classes/LabelAbstract.ts:6
Extended by
Type Parameters
TLabel
TLabel
TProps
TProps extends object = { }
StepIdType
StepIdType = number
Implements
LabelProps<TLabel,StepIdType>
Constructors
Constructor
> new LabelAbstract<TLabel, TProps, StepIdType>(id, props?): LabelAbstract<TLabel, TProps, StepIdType>
Defined in: src/narration/classes/LabelAbstract.ts:13
Parameters
id
string
is the id of the label
props?
LabelProps<TLabel, StepIdType>
is the properties of the label
Returns
LabelAbstract<TLabel, TProps, StepIdType>
Properties
id
> readonly id: string
Defined in: src/narration/classes/LabelAbstract.ts:23
Get the id of the label. This variable is used in the system to get the label by id, RegisteredLabels.get
Accessors
onLoadingLabel
Get Signature
> get onLoadingLabel(): ((stepId, label) => void | Promise<void>) | undefined
Defined in: src/narration/classes/LabelAbstract.ts:61
Is a function that will be executed in onStepStart if the id of the step is 0 and when the user laods a save file. When you load a save file, will be executed all onLoadingLabel functions of the narration.openedLabels. It is useful for example to make sure all images used have been cached
Example
newLabel("id", [], {
onLoadingLabel: async (stepId, label) => {
await Assets.load('path/to/image1.png')
await Assets.load('path/to/image2.png')
}
})
Returns
((stepId, label) => void | Promise<void>) | undefined
Is a function that will be executed in onStepStart if the id of the step is 0 and when the user laods a save file. When you load a save file, will be executed all onLoadingLabel functions of the narration.openedLabels. It is useful for example to make sure all images used have been cached
Example
newLabel("id", [], {
onLoadingLabel: async (stepId, label) => {
await Assets.load('path/to/image1.png')
await Assets.load('path/to/image2.png')
}
})
Implementation of
onStepEnd
Get Signature
> get onStepEnd(): ((stepId, label) => void | Promise<void>) | undefined
Defined in: src/narration/classes/LabelAbstract.ts:68
A function executed after each step. See more <DynamicLink href="/start/labels-advanced#onstepend">here.
Example
const startLabel = newLabel("start", [
async () => {
await showImage("image1", "path/to/image1.png")
await showImage("image2", "path/to/image2.png")
}
], {
onLoadingLabel: async (stepIndex, label) => {
await Assets.load("path/to/image1.png")
await Assets.load("path/to/image2.png")
}
})
Returns
((stepId, label) => void | Promise<void>) | undefined
A function executed after each step. See more <DynamicLink href="/start/labels-advanced#onstepend">here.
Example
const startLabel = newLabel("start", [
async () => {
await showImage("image1", "path/to/image1.png")
await showImage("image2", "path/to/image2.png")
}
], {
onLoadingLabel: async (stepIndex, label) => {
await Assets.load("path/to/image1.png")
await Assets.load("path/to/image2.png")
}
})
Implementation of
onStepStart
Get Signature
> get onStepStart(): ((stepId, label) => void | Promise<void>) | undefined
Defined in: src/narration/classes/LabelAbstract.ts:45
A function executed before each step.
Example
const startLabel = newLabel("start", [
() => {
narration.dialogue = "Step 1"
},
() => {
narration.dialogue = "Step 2"
}
], {
onStepStart: (stepIndex, label) => {
console.log(`Step ${stepIndex} started`)
}
})
Returns
((stepId, label) => void | Promise<void>) | undefined
A function executed before each step.
Example
const startLabel = newLabel("start", [
() => {
narration.dialogue = "Step 1"
},
() => {
narration.dialogue = "Step 2"
}
], {
onStepStart: (stepIndex, label) => {
console.log(`Step ${stepIndex} started`)
}
})
Implementation of
stepCount
Get Signature
> get abstract stepCount(): number
Defined in: src/narration/classes/LabelAbstract.ts:29
Get the number of steps in the label. This variable is used in the system to get the number of steps in the label.
Returns
number
The number of steps in the label
Methods
getStepById()
> abstract getStepById(stepId): StepLabelType<TProps> | undefined
Defined in: src/narration/classes/LabelAbstract.ts:42
Get the step by id
Parameters
stepId
StepIdType
Id of the step
Returns
StepLabelType<TProps> | undefined
The step or undefined if it does not exist
getStepSha()
> abstract getStepSha(stepId): string | undefined
Defined in: src/narration/classes/LabelAbstract.ts:35
Get the sha of the step
Parameters
stepId
StepIdType
Returns
string | undefined