austingray / canvas-game-engine

An HTML 5 canvas game engine.
2 stars 0 forks source link

Selectively redraw Layers #3

Open austingray opened 5 years ago

austingray commented 5 years ago

Layers shouldn't redraw when they don't need to. The logic to trigger a redraw should be moved to the Layer object.

austingray commented 5 years ago

Mentioned in #6

We need a way for objects to notify their layers that they have been updated and therefor need to be redrawn. The challenge here will be moving some draw logic to the Layer level. Currently layers are just explicitly referenced in the object's draw method.

Maybe layers have a subscription interface for adding objects to them, and when the layer is notified that it needs to be updated, it draws everything that is subscribed to it.