Closed videlais closed 11 years ago
Nice demo :).
I've had similar (somewhat bad) experiences when I've tried to go the Foo.prototype = Bar.prototype way of "inheritence" when developing games.
For example if you look at the bottom of http://ippa.se/webgames/unexpected_outcome/game.js .. I combined it with Foo.call(this, options) to get the initializing insterad of a call to super() which would have been done in a pure OO-lang.
It works and I instantly get all the properties from Sprite on a new game-constructor .. but it's also mucks certain things up. I can't put my finger on all the small details that can get confusing with this approach right now, but I'm leaning more and more to using composition nowadays.
If Foo needs sprite stuff... I'll just put an instance of Sprite() in foo.sprite. Sure I'll have to write foo.sprite.x = 123 instead of the shorter foo.x = 123 and so on, but things also becomes clearer in a way.
With that said, ParallaxLayer is a Sprite :) .. https://github.com/ippa/jaws/blob/master/src/parallax.js#L94-L100 and it's been working well.
I've re-written jaws.Text and added in the unit tests. That's the new commit I just added.
Based on the jaws.Sprite code, it uses all the same methods but without any code directly referencing images. It has textAlign, textBaseline, fontFace, and fontSize properties with word-wrapping functionality too.