Skip to content

Commit cf82764

Browse files
Merge pull request 'Updated docs to include modules for each feature' (#14) from chore/update into main
Reviewed-on: https://code.incremental.social/profectus/profectus-docs/pulls/14
2 parents 4c04207 + f5fbfc2 commit cf82764

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

docs/guide/important-concepts/formulas.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ For example, a cost function like `Decimal.pow(amount, 1.05).times(100)` can be
66

77
```ts
88
const myRepeatable = createRepeatable(() => ({
9-
requirements: createCostRequirement(() => ({
10-
resource: points,
9+
requirements: createCostRequirement((): CostRequirementOptions => ({
10+
resource: noPersist(points),
1111
cost: Formula.variable(myRepeatable.amount).pow_base(1.05).times(100)
1212
})),
1313
maximize: true

docs/guide/recipes/particles.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,25 @@ watch(
6363

6464
This code watches for whether the node exists and the `boundingRect` exists, which are required to display the effect. You can additionally watch any other values that would have an impact on the particle effect, like whether or not it should be emitting.
6565

66+
For a "one-shot" animation (one that just gets played once when something happens and then deleted), you can simplify the code a bit:
67+
68+
```ts
69+
watch(achievement.earned, earned => {
70+
const rect = layer.nodes.value[achievement.id]?.rect;
71+
const boundingRect = particles.boundingRect.value;
72+
if (earned && rect != null && boundingRect != null) {
73+
particles.addEmitter(particleEffect).then(emitter => {
74+
emitter.updateOwnerPos(
75+
rect.x + rect.width / 2 - boundingRect.x,
76+
rect.y + rect.height / 2 - boundingRect.y
77+
);
78+
emitter.resetPositionTracking();
79+
emitter.playOnceAndDestroy();
80+
});
81+
}
82+
});
83+
```
84+
6685
## Support Hot Reloading
6786

6887
If you're using hot reloading, you might need to reload the particle effect. Here's an example from Kronos of adding the callback to the particles constructor:

profectus

Submodule profectus updated from 78394b8 to 2c4d95b

0 commit comments

Comments
 (0)