Giter Site home page Giter Site logo

scl's Introduction

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();

scl's People

Contributors

dream93 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.