2 iop520p iop520p 于 2015.07.09 18:07 提问

cocostudio导出的按钮响应的位置会偏左

最近在研究用cocostudio生成ui界面,但是生成的按钮响应位置在按钮图标的右边,百度无果,改界面framesize也没有效果。
想不通是什么原因。用的是cocos2d-x3.6 和cocostudio1.5.
下面是场景init函数的实现,回调的就是结束按钮。

 if (!Layer::init())
    {
        return false;
    }

    cocos2d::ui::Widget* layout = cocostudio::GUIReader::getInstance()->widgetFromJsonFile("MeanMenu_1.json");
    this->addChild(layout);

    Button *Close_Button = (Button*)(ui::Helper::seekWidgetByName(layout, "Close_Butten"));
    Close_Button->addTouchEventListener(this, toucheventselector(HelloWorld::menuCloseCallback));

然后是生成的json文件参数

 {
  "classname": null,
  "name": null,
  "animation": {
    "classname": null,
    "name": "AnimationManager",
    "actionlist": []
  },
  "dataScale": 1,
  "designHeight": 626,
  "designWidth": 900,
  "textures": [],
  "texturesPng": [
    "素材/01f404554c2e040000007cc228c84e.jpg",
    "Resources/CloseSelected.png",
    "Resources/CloseNormal.png"
  ],
  "version": "1.5.0.0",
  "widgetTree": {
    "classname": "Panel",
    "name": null,
    "children": [
      {
        "classname": "Button",
        "name": null,
        "children": [],
        "options": {
          "__type": "ButtonSurrogate:#EditorCommon.JsonModel.Component.GUI",
          "classname": "Button",
          "name": "Close_Butten",
          "ZOrder": 1,
          "actiontag": 55960646,
          "anchorPointX": 1,
          "anchorPointY": 0.5,
          "classType": "CocoStudio.EngineAdapterWrap.CSButton",
          "colorB": 255,
          "colorG": 255,
          "colorR": 255,
          "customProperty": "",
          "flipX": false,
          "flipY": false,
          "height": 40,
          "ignoreSize": true,
          "layoutParameter": null,
          "opacity": 255,
          "positionPercentX": 0.50444454,
          "positionPercentY": 0.23322688,
          "positionType": 0,
          "rotation": 0,
          "scaleX": 1,
          "scaleY": 1,
          "sizePercentX": 0.114444442,
          "sizePercentY": 0.0638977662,
          "sizeType": 0,
          "tag": 41,
          "touchAble": true,
          "useMergedTexture": false,
          "visible": true,
          "width": 40,
          "x": 454,
          "y": 146,
          "capInsetsHeight": 1,
          "capInsetsWidth": 1,
          "capInsetsX": 0,
          "capInsetsY": 0,
          "disabled": null,
          "disabledData": {
            "path": null,
            "plistFile": null,
            "resourceType": 0
          },
          "fontName": "微软雅黑",
          "fontSize": 14,
          "fontType": 0,
          "normal": null,
          "normalData": {
            "path": "Resources/CloseSelected.png",
            "plistFile": "",
            "resourceType": 0
          },
          "pressed": null,
          "pressedData": {
            "path": "Resources/CloseNormal.png",
            "plistFile": "",
            "resourceType": 0
          },
          "scale9Enable": false,
          "scale9Height": 40,
          "scale9Width": 40,
          "text": "",
          "textColorB": 255,
          "textColorG": 255,
          "textColorR": 255
        }
      }
    ],
    "options": {
      "__type": "PanelSurrogate:#EditorCommon.JsonModel.Component.GUI",
      "classname": "Panel",
      "name": "Panel_18",
      "ZOrder": 0,
      "actiontag": -1,
      "anchorPointX": 0,
      "anchorPointY": 0,
      "classType": "CocoStudio.EngineAdapterWrap.CSPanel",
      "colorB": 255,
      "colorG": 255,
      "colorR": 255,
      "customProperty": "",
      "flipX": false,
      "flipY": false,
      "height": 626,
      "ignoreSize": false,
      "layoutParameter": null,
      "opacity": 255,
      "positionPercentX": 0,
      "positionPercentY": 0,
      "positionType": 0,
      "rotation": 0,
      "scaleX": 1,
      "scaleY": 1,
      "sizePercentX": 1,
      "sizePercentY": 1,
      "sizeType": 0,
      "tag": 33,
      "touchAble": false,
      "useMergedTexture": false,
      "visible": true,
      "width": 900,
      "x": 0,
      "y": 0,
      "adaptScreen": false,
      "backGroundImage": null,
      "backGroundImageData": {
        "path": "素材/01f404554c2e040000007cc228c84e.jpg",
        "plistFile": "",
        "resourceType": 0
      },
      "backGroundScale9Enable": false,
      "bgColorB": 255,
      "bgColorG": 200,
      "bgColorOpacity": 0,
      "bgColorR": 150,
      "bgEndColorB": 255,
      "bgEndColorG": 200,
      "bgEndColorR": 150,
      "bgStartColorB": 255,
      "bgStartColorG": 255,
      "bgStartColorR": 255,
      "capInsetsHeight": 1,
      "capInsetsWidth": 1,
      "capInsetsX": 0,
      "capInsetsY": 0,
      "clipAble": false,
      "colorType": 1,
      "layoutType": 0,
      "vectorX": 0,
      "vectorY": -0.5
    }
  }
}

有大神能帮忙看看到底是什么问题

2个回答

iop520p
iop520p   2015.07.09 20:07

我找到问题所在了,是没有调整好窗口分辨率,因为分辨率太大导致错位

chenqiai0
chenqiai0   2015.07.11 00:03

你用最新版本的cocos studio

Csdn user default icon
上传中...
上传图片
插入图片