Skip to content
/ scl Public
forked from dream93/scl

SCL is simple component and libs for cocos creator.

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

MrWDJ/scl

 
 

Repository files navigation

SCL

SCL是一套基于CocosCreator的极简(Simple)、基于组件(Component)以及类库(Libs)的开源框架,主要服务于休闲类游戏的快速开发。

弹框管理使用

  1. 在弹框之前初始化
PopupManager.instance.init();
  1. 将弹框制作成prefab,并挂在继承PopupBase的脚本组件
    /**
     * 是否设置点击拦截
     */
    @property(CCBoolean)
    blockInput: boolean = true;

    /**
     * 是否显示弹框动画
     */
    @property(CCBoolean)
    anim: boolean = true;

    /**
     * 弹框动画类型
     */
    @property({
        type: Enum(AnimType),
        visible() {
            return (this as any).anim;
        }
    })
    animType: AnimType = AnimType.SCALE;
  1. 显示弹框
PopupManager.instance.show(option: { name?: string, prefab?: Prefab, path?: string, siblingIndex?: number, params?: any, keep?: boolean });
参数 类型 默认值 说明
name string null 自定义弹框名字
prefab Prefab null Prefab
path string null 动态加载的路径
siblingIndex number 0 层级
params any null 传递的参数
keep boolean false 是否保留当前弹框
  1. 隐藏弹框
PopupManager.instance.hide(name:string);
// 隐藏所有
PopupManager.instance.hideAll();
  1. 销毁弹框
PopupManager.instance.remove(name:string)
// 销毁所有
PopupManager.instance.removeAll();
  1. 获取当前弹框
// 弹框Node,如果当前没有弹框,返回null
PopupManager.instance.getCurrentPopup():Node|null;
// 弹框名字,如果当前没有弹框,则返回null
PopupManager.instance.getCurrentName(): string | null;
  1. 获取某个弹框
PopupManager.instance.getPopup(name: string): Node | null;

本地化存储

API

  1. 初始化密钥
SqlUtil.init(key: string, iv: string);
  1. 存储
SqlUtil.set(key: string, value: any);
  1. 取出
SqlUtil.get(key: string, defaultValue?: any);
  1. 移除
SqlUtil.remove(key: string);
  1. 清空
SqlUtil.clear();

组件

CanvasAdapter

挂载后,选择模式

  • EXACT_FIT = ResolutionPolicy.EXACT_FIT, // 拉伸适配,目前已不被支持
  • NO_BORDER = ResolutionPolicy.NO_BORDER, // 铺满屏幕
  • SHOW_ALL = ResolutionPolicy.SHOW_ALL, // 内容完整显示,裁剪区域
  • FIXED_HEIGHT = ResolutionPolicy.FIXED_HEIGHT, // 适配高
  • FIXED_WIDTH = ResolutionPolicy.FIXED_WIDTH, // 适配宽
  • CUSTOM = 9 // 完整显示内容,但不裁剪区域

吐司

Toast.makeTest(node: Node|null, test: string, time:number).show();

About

SCL is simple component and libs for cocos creator.

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 79.7%
  • TypeScript 20.3%