I apologize for including two separate features in one pull request - they ended up that way. I can separate the commits if needed, but they're each fairly small.
Not all sprites necessarily have points or need them, but the engine breaks if Sprites don't have provided points, when it tries to create collision points. I just updated the code so that no collision points are generated if no points exist (this problem will never come up anyway if you're using the 2d module). The change makes simple sprite animations without need for collision detection easy and lightweight.
I made it possible to extend components. They are, after all, classes just like any other, except that they don't have a neat interface for being extended themselves (since they've clearly been intended to just be attached to other objects). The use case that inspired me to code in this feature is wanting to override some elements of platformerControls, without having to duplicate the entire class.
I adapted the existing component creation method to accommodate extension. Pass in the parent as the third argument. You can use the following to create a component called 'endlessRunnerControls' that inherits from 'platformerControls' but overrides the step function:
Q.component('endlessRunnerControls', {
step: function (dt) {
...
}
}, 'platformerControls');
I apologize for including two separate features in one pull request - they ended up that way. I can separate the commits if needed, but they're each fairly small.
I adapted the existing component creation method to accommodate extension. Pass in the parent as the third argument. You can use the following to create a component called 'endlessRunnerControls' that inherits from 'platformerControls' but overrides the step function: