Skip to content

Commit

Permalink
Makes onFixedUpdate attach to fixedUpdate (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
mflerackers authored Aug 31, 2024
1 parent 17a57bc commit 678eb5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions examples/fixedUpdate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kaplay();

let fixedCount = 0;
let count = 0;

onFixedUpdate(() => {
fixedCount++;
});

onUpdate(() => {
count++;
debug.log(
`${fixedDt()} ${Math.floor(fixedCount / time())} ${dt()} ${
Math.floor(count / time())
}`,
);
});
2 changes: 1 addition & 1 deletion src/game/events/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function on<Ev extends GameObjEventNames | string & {}>(

export const onFixedUpdate = overload2(
(action: () => void): KEventController => {
const obj = game.root.add([{ update: action }]);
const obj = game.root.add([{ fixedUpdate: action }]);
return {
get paused() {
return obj.paused;
Expand Down

0 comments on commit 678eb5a

Please sign in to comment.