Skip to content

MenuItemSprite's automatic init logic for sprite is incorrect #1161

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

Closed
pandamicro opened this issue Dec 3, 2014 · 1 comment
Closed

MenuItemSprite's automatic init logic for sprite is incorrect #1161

pandamicro opened this issue Dec 3, 2014 · 1 comment

Comments

@pandamicro
Copy link
Contributor

This is the ctor function:

ctor: function (normalSprite, selectedSprite, three, four, five) {
    cc.MenuItem.prototype.ctor.call(this);
    this._normalImage = null;
    this._selectedImage = null;
    this._disabledImage = null;

    if (selectedSprite !== undefined) {
        normalSprite = normalSprite;
        selectedSprite = selectedSprite;
        var disabledImage, target, callback;
        //when you send 4 arguments, five is undefined
        if (five !== undefined) {
            disabledImage = three;
            callback = four;
            target = five;
        } else if (four !== undefined && cc.isFunction(four)) {
            disabledImage = three;
            callback = four;
        } else if (four !== undefined && cc.isFunction(three)) {
            target = four;
            callback = three;
            disabledImage = new cc.Sprite(selectedSprite);
        } else if (three === undefined) {
            disabledImage = new cc.Sprite(selectedSprite);
        }
        this.initWithNormalSprite(normalSprite, selectedSprite, disabledImage, callback, target);
    }
},

It use a sprite to initialize another sprite which will fail

@pandamicro
Copy link
Contributor Author

closed via cocos2d/cocos2d-html5#2481

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