You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: projects/add-easing-to-your-game-animations-with-phaser/add-easing-to-your-game-animations-with-phaser.mdx
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -212,7 +212,7 @@ function create() {
212
212
213
213
This makes the player walk across the screen automatically.
214
214
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.
216
216
-`targets: player` is the object to animate.
217
217
-`x: 800` is the target x-position (moves the sprite horizontally to 800).
218
218
-`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:
@@ -299,7 +299,7 @@ As you’re testing these out, think about how each easing changes the feeling o
299
299
300
300
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.
301
301
302
-
Let’s zoom into the `this.tweens.add` function.
302
+
Let’s zoom into the `this.tweens.add()` function.
303
303
304
304
```jsx
305
305
this.tweens.add({
@@ -327,7 +327,7 @@ Try replacing the built-in function name in your code with the mathematical func
327
327
328
328
So, why does this work? Let’s break down the logic of the easing function itself.
329
329
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.
331
331
332
332
`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.
333
333
@@ -343,7 +343,7 @@ Just like the linear graph from before.
0 commit comments