Skip to content
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

CCMenuItemSprite images not visible (w/ fix) #46

Closed
mochibits opened this issue Nov 2, 2011 · 2 comments
Closed

CCMenuItemSprite images not visible (w/ fix) #46

mochibits opened this issue Nov 2, 2011 · 2 comments

Comments

@mochibits
Copy link

Selected and disabled image not being displayed. Visible flags not being set. See code below for my fix. Maybe there's a better way though.

@Override
public void draw(GL10 gl) {
    if (isEnabled_) {
        if (isSelected_) {
            normalImage_.setVisible(false);
            selectedImage_.setVisible(true);
            selectedImage_.draw(gl);
        } else {
            normalImage_.setVisible(true);
            selectedImage_.setVisible(false);
            normalImage_.draw(gl);
        }
    } else {
        if (disabledImage_ != null) {
            normalImage_.setVisible(false);
            disabledImage_.setVisible(true);
            disabledImage_.draw(gl);

            // disabled image was not provided
        } else {
            normalImage_.setVisible(true);
            disabledImage_.setVisible(false);
            normalImage_.draw(gl);
        }
    }
}
@ZhouWeikuan
Copy link
Owner

In CCNode's visit, the visible flags has been taken into consideration,
isn't it?
for the draw function, it doesn't need to set the visibility, it just show
the visible objects..

2011/11/3 Kyle <
reply@reply.github.com>

Selected and disabled image not being displayed. Visible flags not being
set. See code below for my fix. Maybe there's a better way though.

   @Override
   public void draw(GL10 gl) {
           if (isEnabled_) {
                   if (isSelected_) {
                           normalImage_.setVisible(false);
                           selectedImage_.setVisible(true);
                           selectedImage_.draw(gl);
                   } else {
                           normalImage_.setVisible(true);
                           selectedImage_.setVisible(false);
                           normalImage_.draw(gl);
                   }
           } else {
                   if (disabledImage_ != null) {
                           normalImage_.setVisible(false);
                           disabledImage_.setVisible(true);
                           disabledImage_.draw(gl);

                           // disabled image was not provided
                   } else {
                           normalImage_.setVisible(true);
                           disabledImage_.setVisible(false);
                           normalImage_.draw(gl);
                   }
           }
   }

Reply to this email directly or view it on GitHub:
#46

This is Zhou, Weikuan(Ϊ)

@mochibits
Copy link
Author

Thanks for the (real) fix! =)

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

2 participants