Flex设置PopUpManager创建modal(模态)窗口的背景样式

有一个需求 , 使用PopUpManager弹出的窗口modal模式不可操作的地方颜色太浅, 这样弹出的窗口就不够突出, 搜了下没发现解决办法, 翻看了PopUpManagerImpl源码 , 找到了创建modal模式窗口使用的两个样式名称.

这样在application初始的时候 更改一下这两个样式就可以了

//设置弹出窗口modal模式背景颜色和透明度
FlexGlobals.topLevelApplication.setStyle("modalTransparencyColor",0x000000);
FlexGlobals.topLevelApplication.setStyle("modalTransparency",0.6);

 

转载于:https://www.cnblogs.com/gongchen/p/3558279.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Cocos Creator中使用TypeScript来创建弹窗控制器,你可以按照以下步骤进行操作: 1. 创建一个名为PopupManager的类,该类将负责管理所有弹窗的打开和关闭操作。 ```typescript export class PopupManager { private static _instance: PopupManager = null; private _popupStack: cc.Node[] = []; private _popupLayer: cc.Node = null; public static getInstance(): PopupManager { if (PopupManager._instance == null) { PopupManager._instance = new PopupManager(); } return PopupManager._instance; } private constructor() { this._popupLayer = new cc.Node(); this._popupLayer.name = "PopupLayer"; cc.director.getScene().addChild(this._popupLayer); } public pushPopup(popup: cc.Node) { if (popup == null) { return; } this._popupLayer.addChild(popup); this._popupStack.push(popup); } public popPopup() { if (this._popupStack.length > 0) { let popup = this._popupStack.pop(); popup.removeFromParent(true); } } } ``` 2. 创建一个名为PopupBase的类,该类将作为所有弹窗的基类,提供弹窗的打开和关闭方法。你可以在该类的onLoad方法中进行初始化操作。 ```typescript export class PopupBase extends cc.Component { public onLoad() { // 初始化弹窗界面 this.initView(); } public initView() { // 子类需要实现该方法,用于初始化弹窗界面 } public show() { // 弹出弹窗 PopupManager.getInstance().pushPopup(this.node); } public hide() { // 隐藏弹窗 PopupManager.getInstance().popPopup(); } } ``` 3. 创建一个名为MyPopup的类,该类将作为你的具体弹窗控制器,在该类中继承PopupBase类。 ```typescript export class MyPopup extends PopupBase { private _closeBtn: cc.Node = null; public initView() { // 初始化弹窗界面 this._closeBtn = this.node.getChildByName("CloseBtn"); this._closeBtn.on(cc.Node.EventType.TOUCH_END, this.onCloseBtnClick, this); } private onCloseBtnClick() { // 关闭弹窗 this.hide(); } } ``` 4. 在场景中添加一个空节点作为弹窗容器,并将MyPopup预制体添加到该节点下。 ```typescript const {ccclass, property} = cc._decorator; @ccclass export class MainScene extends cc.Component { @property(cc.Prefab) private _myPopupPrefab: cc.Prefab = null; private _myPopup: cc.Node = null; public onLoad() { // 加载弹窗预制体 this._myPopup = cc.instantiate(this._myPopupPrefab); } public onBtnShowPopupClick() { // 显示弹窗 this._myPopup.getComponent(MyPopup).show(); } } ``` 现在你已经创建了一个弹窗控制器,可以通过该控制器来方便地管理多个弹窗,并在需要的时候打开或关闭它们。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值