公司新项目主页上的ui 需要做成 横竖屏切换的两种效果。
经过讨论,想出了一个方案,就是利用cocos stdio 的 animation 来控制ui中的元素。
利用一帧的时间来平移 ui中的元素,将ui摆放到具体的位置中。
当接收到 横竖屏切换的时候 只需要调用类似于:
var json = ccs.load("ui/uiCommonLayer.json");
this.m_basePannel = json.node;
this.addChild(this.m_basePannel);
this.action = json.action;
this.m_basePannel.runAction(this.action);
this.m_action.gotoFrameAndPlay(5, 0, false); 或 this.m_action.play("screenToSwitch", false);
就可以实现下面切换ui布局的操作: