Skip to content

Background color of panel from cocos studio 2 doesnt work #2753

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
EntityB opened this issue Mar 19, 2015 · 2 comments
Closed

Background color of panel from cocos studio 2 doesnt work #2753

EntityB opened this issue Mar 19, 2015 · 2 comments

Comments

@EntityB
Copy link

EntityB commented Mar 19, 2015

TimelineParser-2.x doesn't parse background color for panel component, (as it does for scrollview, listview and pageview)

Method parser.initPanel
https://github.com/cocos2d/cocos2d-html5/blob/develop/extensions/cocostudio/loader/parsers/timelineParser-2.x.js#L366

should contain something similar like here:

https://github.com/cocos2d/cocos2d-html5/blob/develop/extensions/cocostudio/loader/parsers/timelineParser-2.x.js#L665

@VisualSJ
Copy link
Contributor

@EntityB
Sorry, I don't understand what you mean...
https://github.com/cocos2d/cocos2d-html5/blob/develop/extensions/cocostudio/loader/parsers/timelineParser-2.x.js#L428
There is setting Layout backgroundColor

Thanks.~~~

VisualSJ :)

@EntityB
Copy link
Author

EntityB commented Mar 20, 2015

@VisualSJ

No problem, I will try to explain this better.

I have very simple test project in cocos studio 2.1.5 where are two panels. Red with 50% transparency and green with 50% transparency.

This is how I setup the background color of the red one:
color-setup

After publishing into json, structure looks like this:

"Children": [
      {
        "BackColorAlpha": 128,
        "ComboBoxIndex": 1,
        "SingleColor": {
          "R": 0,
          "B": 0
        },
        "FirstColor": {
          "R": 150,
          "G": 200
        },
        "EndColor": {},
        "ColorVector": {
          "ScaleY": 1.0
        },
        "Scale9Width": ...
        ...
      },
      {
        "BackColorAlpha": 127,
        "ComboBoxIndex": 1,
        "SingleColor": {
          "G": 0,
          "B": 0
        },
        "FirstColor": {
          "R": 150,
          "G": 200
        },
        "EndColor": {},
        "ColorVector": {
          "ScaleY": 1.0
        },
        ...
      }
]

Please notice I used fill: solid. Then exported color is presented as json["SingleColor"]. FirstColor and EncColor is also present, but I think it is not correct behavior since I didn't choose gradient fill style.

Better implementation already exists here:
https://github.com/cocos2d/cocos2d-html5/blob/develop/extensions/cocostudio/loader/parsers/timelineParser-2.x.js#L686

    var firstColor = json["FirstColor"];
    var endColor = json["EndColor"];
    if(firstColor && endColor){
       ...
    }else{
        widget.setBackGroundColor(getColor(json["SingleColor"]));
    }

Except I belive condition if(firstColor && endColor) should be false in case of "fill: solid" and Im not sure it will be since both of these colors are present in json structure.

Right now background colors are not red and green as expected.

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