[Cocos2dx 3.10 JS] Accessing a progress bar inside a layer..

  • newb007
    Likes 0

    Problem Description

    Hi, 

    I built a scene in cocos studio. This scene has two layers: background and ui. In ui layer, I have a progress bar and I just want to access it. 

    I did the following. 

    var mainscene = css.load(res.MainScene_json); 

    this.addChild(mainscene.node); 

    var uiLayer = mainscene.getChildByName(“loadingUi_layer”);

    var progressBar = uiLayer.getChildByName(“loadingBar”); 

    progressBar.setPercent(10); 

    When I run this code on simulator, all I got is a black screen. However if commented out those 3 lines after this.addChild(mainscene.node), then the it will display the entire scene.. 

    Baffled and confused.. 

  • Sonar Systems admin
    Likes 0

    Try commenting out one line at a time so we can figure out the root cause.

  • newb007
    Likes 0

    Yep I did that, the only way it would work if I completely commented out all 3 lines. Also, how do you set up remote debugging for xcode with firefox ? I came across a link but it’s in obj C, and outdated. Help please :) Thanks a lot for your help so far. 

    This is the json for mainscene.. I’m using the latest version of cocos studio and cocos2dx 

    {

      "ID": "a2ee0952-26b5-49ae-8bf9-4f1d6279b798",

      "Version": "3.10.0.0",

      "Name": "MainScene",

      "Content": {

        "Content": {

          "Animation": {

            "Duration": 0,

            "Speed": 1.0,

            "Timelines": [],

            "ctype": "TimelineActionData"

          },

          "AnimationList": [],

          "ObjectData": {

            "Children": [

              {

                "FileData": {

                  "Type": "Normal",

                  "Path": "LlBg_layer.json",

                  "Plist": ""

                },

                "StretchWidthEnable": false,

                "StretchHeightEnable": false,

                "InnerActionSpeed": 1.0,

                "AnchorPoint": {},

                "Position": {

                  "X": 0.0,

                  "Y": 0.0

                },

                "Scale": {

                  "ScaleX": 1.0,

                  "ScaleY": 1.0

                },

                "CColor": {},

                "IconVisible": true,

                "PositionPercentXEnabled": true,

                "PositionPercentYEnabled": true,

                "PrePosition": {

                  "X": 0.0,

                  "Y": 0.0

                },

                "PreSize": {

                  "X": 1.0,

                  "Y": 1.0

                },

                "Tag": 55,

                "ActionTag": 1962991850,

                "Size": {

                  "X": 1920.0,

                  "Y": 1080.0

                },

                "Name": "llBg_layer",

                "ctype": "ProjectNodeObjectData"

              },

              {

                "FileData": {

                  "Type": "Normal",

                  "Path": "loadingUI_layer.json",

                  "Plist": ""

                },

                "StretchWidthEnable": false,

                "StretchHeightEnable": false,

                "InnerActionSpeed": 1.0,

                "AnchorPoint": {},

                "Position": {

                  "X": 0.0,

                  "Y": 0.0

                },

                "Scale": {

                  "ScaleX": 1.0,

                  "ScaleY": 1.0

                },

                "CColor": {},

                "IconVisible": true,

                "PositionPercentXEnabled": true,

                "PositionPercentYEnabled": true,

                "PrePosition": {

                  "X": 0.0,

                  "Y": 0.0

                },

                "PreSize": {

                  "X": 1.0,

                  "Y": 1.0

                },

                "Tag": 58,

                "ActionTag": 717803821,

                "Size": {

                  "X": 1920.0,

                  "Y": 1080.0

                },

                "Name": "loadingUi_layer",

                "ctype": "ProjectNodeObjectData"

              }

            ],

            "Size": {

              "X": 1920.0,

              "Y": 1080.0

            },

            "Name": "Scene",

            "ctype": "SingleNodeObjectData"

          },

          "UsedResources": [

            "LlBg_layer.json",

            "loadingUI_layer.json"

          ],

          "ctype": "GameFileData"

        }

      },

      "Type": "Scene"

    }

     

  • Sonar Systems admin
    Likes 0

    A lot of features don’t work anymore because they have been disabled. Have you tried loading in just a simple button using our Cocos API Guide 

     

    http://cocos.sonarlearning.co.uk/

  • newb007
    Likes 0

    You mean just create it from scratch using code instead of cocos studio ? 

  • Sonar Systems admin
    Likes 0

    Honestly that would be best, wait until the studio and creator mature then use it.

  • newb007
    Likes 0

    Thanks for your advice. 

    I guess we will stick to cocos2d-x only.. 

     

     

  • Sonar Systems admin
    Likes 0

    It is best

     

    Feel free to post anymore questions you have.

Login to reply