Skip to content

Commit 487d0ad

Browse files
committed
Update add-easing-to-your-game-animations-with-phaser.mdx
1 parent b3e30c7 commit 487d0ad

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

projects/add-easing-to-your-game-animations-with-phaser/add-easing-to-your-game-animations-with-phaser.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function create() {
212212

213213
This makes the player walk across the screen automatically.
214214

215-
- `this.tweens.add` moves or changes properties of objects smoothly over time.
215+
- `this.tweens.add()` moves or changes properties of objects smoothly over time.
216216
- `targets: player` is the object to animate.
217217
- `x: 800` is the target x-position (moves the sprite horizontally to 800).
218218
- `duration: 3000` is the time in milliseconds (3 seconds) for the movement.
@@ -230,15 +230,15 @@ When you run the code, you should see something like this:
230230

231231
<ImageZoom
232232
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/linear.gif"
233-
style={{ width: "80%", height: "auto" }}
233+
style={{ width: "50%", height: "auto" }}
234234
alt="codedex character linear walk"
235235
/>
236236

237237
Here’s a graph visualizing the animation curve:
238238

239239
<ImageZoom
240240
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/linearGraph.gif"
241-
style={{ width: "50%", height: "auto" }}
241+
style={{ width: "25%", height: "auto" }}
242242
alt="linear graph"
243243
/>
244244

@@ -257,13 +257,13 @@ As you saw above, there are 32 different types of easing we can apply to this ch
257257
"Sine.easeInOut","Expo.easeInOut","Circ.easeInOut","Back.easeInOut","Bounce.easeInOut"
258258
```
259259

260-
Inside `this.tweens.add`, try changing `ease` from `Linear` to one of the options above.
260+
Inside `this.tweens.add()`, try changing `ease` from `Linear` to one of the options above.
261261

262262
A nice subtle one to try is `Sine.easeInOut`:
263263

264264
<ImageZoom
265265
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/sine.gif"
266-
style={{ width: "80%", height: "auto" }}
266+
style={{ width: "50%", height: "auto" }}
267267
alt="codedex character sine ease in out sine walk"
268268
/>
269269

@@ -273,23 +273,23 @@ Here’s a graph visualizing the animation curve:
273273

274274
<ImageZoom
275275
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/easeInOutSine.gif"
276-
style={{ width: "50%", height: "auto" }}
276+
style={{ width: "25%", height: "auto" }}
277277
alt="ease in out sine graph"
278278
/>
279279

280280
They can get pretty wild. Here’s `Bounce.easeInOut` in action:
281281

282282
<ImageZoom
283283
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/bounce.gif"
284-
style={{ width: "80%", height: "auto" }}
284+
style={{ width: "50%", height: "auto" }}
285285
alt="codedex character bounce ease in out walk"
286286
/>
287287

288288
Here’s a graph visualizing that one:
289289

290290
<ImageZoom
291291
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/easeInOutBounce.gif"
292-
style={{ width: "50%", height: "auto" }}
292+
style={{ width: "25%", height: "auto" }}
293293
alt="bounce ease in out graph"
294294
/>
295295

@@ -299,7 +299,7 @@ As you’re testing these out, think about how each easing changes the feeling o
299299

300300
If you want to customize it even further, you can actually go outside the box of built-in easing functions, and make your own. In order to do that, we need to understand exactly how the math behind easing functions works.
301301

302-
Let’s zoom into the `this.tweens.add` function.
302+
Let’s zoom into the `this.tweens.add()` function.
303303

304304
```jsx
305305
this.tweens.add({
@@ -327,7 +327,7 @@ Try replacing the built-in function name in your code with the mathematical func
327327

328328
So, why does this work? Let’s break down the logic of the easing function itself.
329329

330-
Setting values in `this.tweens.add` controls how a value changes over time. In this case, how the player’s `x` position moves `800` pixels to the right over the course of `3000` milliseconds, or 3 seconds.
330+
Setting values in `this.tweens.add()` controls how a value changes over time. In this case, how the player’s `x` position moves `800` pixels to the right over the course of `3000` milliseconds, or 3 seconds.
331331

332332
`t` stands for normalized time, or how far along the animation is between the start and the end, represented as a value between `0` and `1`. So, the value of `t` goes from `0` to `1` over the course of `3000` milliseconds, the tween’s duration.
333333

@@ -343,7 +343,7 @@ Just like the linear graph from before.
343343

344344
<ImageZoom
345345
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/linearGraph.gif"
346-
style={{ width: "50%", height: "auto" }}
346+
style={{ width: "25%", height: "auto" }}
347347
alt="linear graph"
348348
/>
349349

@@ -370,7 +370,7 @@ Woah woah woah! Why is the animation only 3.1% complete at `t = 0.5`? Isn’t th
370370

371371
<ImageZoom
372372
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/easeInExpo.gif"
373-
style={{ width: "50%", height: "auto" }}
373+
style={{ width: "25%", height: "auto" }}
374374
alt="expo ease in graph"
375375
/>
376376

@@ -397,7 +397,7 @@ this.tweens.add({
397397
```
398398
<ImageZoom
399399
src="https://raw.githubusercontent.com/codedex-io/projects/main/projects/add-easing-to-your-game-animations-with-phaser/assets/easeOutElastic.gif"
400-
style={{ width: "50%", height: "auto" }}
400+
style={{ width: "25%", height: "auto" }}
401401
alt="elastic ease out graph"
402402
/>
403403

0 commit comments

Comments
 (0)