cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Button defaultProps breaks all existing code prior to 10th of Jan #102

Closed fariazz closed 10 years ago

fariazz commented 10 years ago

In this commit: https://github.com/cykod/Quintus/commit/68da27b7e7ea8b43b951f5f813d7673e7c6935c1

The button parameters were changed from:

Q.UI.Button = Q.UI.Container.extend("UI.Button", {
    init: function(p,callback) {

to:

Q.UI.Button = Q.UI.Container.extend("UI.Button", {
    init: function(p, defaultProps, callback) {

After which all Button usage prior to that date is now broken, including the UI and the audio examples that come with quintus.

I think the defaultProps parameter should be moved to the end like this so this doesn't alter the existing API:

Q.UI.Button = Q.UI.Container.extend("UI.Button", {
    init: function(p, callback, defaultProps) {

If it won't be changed maybe it would be good to add a note on the new version that warns developers to update their previous code..

jerone commented 10 years ago

Confirmed and reported here also: https://github.com/cykod/Quintus/pull/78#issuecomment-35431924

krzysu commented 10 years ago

That is my fault. I needed to extend UI.Button, like here https://github.com/krzysu/game-off-2013/blob/master/app/scripts/game/sprites/ui/level_button.coffee. Quintus wasn't supporting that. So I added defaultProps to library source. But that introduced the problem you are describing. I found this workaround and used it in my game. Just add type to properties of your UI.Button sprite type: Q.SPRITE_UI | Q.SPRITE_DEFAULT. I will fix that and send pull request as soon as possible. One more example here: https://github.com/krzysu/game-off-2013/blob/master/app/scripts/game/scenes/level_summary.coffee#L76-L86

cykod commented 10 years ago

Changed Q.UI.Button parameter order back to callback