Commit 5bcec6f2 authored by 李维's avatar 李维

添加点击按钮区域外可隐藏按钮功能

parent 757d6bf5
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -183,6 +183,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -183,6 +183,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
showCloseBtn: Function = null; showCloseBtn: Function = null;
initActionButton() { initActionButton() {
const canvas = cc.find("Canvas"); const canvas = cc.find("Canvas");
const actionBtnMaskBg = cc.find("Canvas/ActionBtnMaskBg");
const actionBtnContainer = cc.find("Canvas/ActionBtn"); const actionBtnContainer = cc.find("Canvas/ActionBtn");
const defaultBtn = cc.find("btn_default", actionBtnContainer) const defaultBtn = cc.find("btn_default", actionBtnContainer)
const submitBtn = cc.find("btn_submit_new", actionBtnContainer) const submitBtn = cc.find("btn_submit_new", actionBtnContainer)
...@@ -226,6 +227,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -226,6 +227,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const showSubmitBtn = () => { const showSubmitBtn = () => {
submitBtn.opacity = 0; submitBtn.opacity = 0;
submitBtn.active = true; submitBtn.active = true;
// 启用透明背景,点击按钮区域外 按钮收回
actionBtnMaskBg.active = true;
cc.tween(actionBtnContainer).to(0.1, {y: topY, scale: 1}).start(); cc.tween(actionBtnContainer).to(0.1, {y: topY, scale: 1}).start();
cc.tween(submitBtn).to(0.1, {opacity: 255}).start(); cc.tween(submitBtn).to(0.1, {opacity: 255}).start();
cc.tween(defaultBtn).to(0.1, {opacity: 0}).call(()=>{ cc.tween(defaultBtn).to(0.1, {opacity: 0}).call(()=>{
...@@ -236,6 +239,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -236,6 +239,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const showReplayBtn = () => { const showReplayBtn = () => {
replayBtn.opacity = 0; replayBtn.opacity = 0;
replayBtn.active = true; replayBtn.active = true;
// 启用透明背景,点击按钮区域外 按钮收回
actionBtnMaskBg.active = true;
cc.tween(actionBtnContainer).to(0.1, {y: topY, scale: 1}).start(); cc.tween(actionBtnContainer).to(0.1, {y: topY, scale: 1}).start();
cc.tween(replayBtn).to(0.1, {opacity: 255}).start(); cc.tween(replayBtn).to(0.1, {opacity: 255}).start();
cc.tween(defaultBtn).to(0.1, {opacity: 0}).call(()=>{ cc.tween(defaultBtn).to(0.1, {opacity: 0}).call(()=>{
...@@ -263,6 +268,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -263,6 +268,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
// }).start(); // }).start();
} }
actionBtnMaskBg.on("click", ()=>{
showDefaultBtn();
actionBtnMaskBg.active = false;
})
defaultBtn.on("click", ()=>{ defaultBtn.on("click", ()=>{
if(this.submitted) { if(this.submitted) {
showReplayBtn() showReplayBtn()
...@@ -273,6 +283,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -273,6 +283,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
submitBtn.on("click", async ()=>{ submitBtn.on("click", async ()=>{
// await showDefaultBtn(); // await showDefaultBtn();
// 隐藏掉背景 保持返回按钮一直显示
actionBtnMaskBg.active = false;
this.submit(); this.submit();
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment