Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug Module Clocks Not Accurate? #66

Open
Joncom opened this issue Sep 8, 2019 · 0 comments
Open

Debug Module Clocks Not Accurate? #66

Joncom opened this issue Sep 8, 2019 · 0 comments

Comments

@Joncom
Copy link
Collaborator

Joncom commented Sep 8, 2019

This issue comes from: https://impactjs.com/forums/impact-engine/bug-debug-module-clocks-not-accurate

Someone correct me if I'm wrong here, but it seems that the debug module clocks are not necessarily accurate. Or at least, not what you might expect.

This is due to the order of operations that occur when classes inject/extend to and from each other.

For example, the debug module injects a clock into ig.Game:

ig.Game.inject({
    draw: function() {
        ig.graph.beginClock('draw');
        this.parent();
        ig.graph.endClock('draw');
    }
});

However, since this module is always loaded before our custom game class (lib/game/main.js), that means any modifications to draw we make in our game class won't be clocked.

MyGame = ig.Game.extend({
    // ...
    
    // this draw function wraps after the debug version
    draw: function() {
        this.parent(); // will be clocked
        this.drawGUI(); // will NOT be clocked
    }
});

The same applies to the other clocks, such as the "update" clock. It's only measuring the ig.Game.update logic, which includes updateEntities and checkEntities for example, but none of your own custom game code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant