Skip to content

Commit

Permalink
adding duration threshold for camera move event
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Feb 10, 2024
1 parent 9624444 commit afbc8e2
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions base/game_events/CameraMoveEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,24 @@ export class CameraMoveEvent extends GameEvent {
const easing = point.easing ? _.get(Phaser.Easing, point.easing) : Phaser.Easing.Linear.None;
let promise_resolve;
const promise = new Promise(resolve => (promise_resolve = resolve));
this.game.add
.tween(this.game.camera)
.to(
{
x: x,
y: y,
},
duration,
easing,
true
)
.onComplete.addOnce(promise_resolve);
if (duration >= 30) {
this.game.add
.tween(this.game.camera)
.to(
{
x: x,
y: y,
},
duration,
easing,
true
)
.onComplete.addOnce(promise_resolve);
} else {
this.game.camera.x = x;
this.game.camera.y = y;
promise_resolve();
}
await promise;
}
if (this.reset_follow && camera_was_following) {
Expand Down

0 comments on commit afbc8e2

Please sign in to comment.