• Cocos Creator提示框封装





    // Learn cc.Class:
    // - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
    // - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
    // Learn Attribute:
    // - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
    // - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
    // Learn life-cycle callbacks:
    // - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
    // - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html

    cc.Class({
    extends: cc.Component,

    properties: {
    // foo: {
    // // ATTRIBUTES:
    // default: null, // The default value will be used only when the component attaching
    // // to a node for the first time
    // type: cc.SpriteFrame, // optional, default is typeof default
    // serializable: true, // optional, default is true
    // },
    // bar: {
    // get () {
    // return this._bar;
    // },
    // set (value) {
    // this._bar = value;
    // }
    // },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },
    showMessage:function(msg){

    if(msg==null)return


    this.speedtimes = 30
    this.data = msg //
    this.init(this.data)

    //var data ={type:1,str=""}
    //cc.hb.eventMgr.emit("kkkkk",data);
    },
    init:function(string,time){//初始化函数

    cc.log("tip string", string)
    if(string){
    this.node.getChildByName("label").getComponent(cc.Label).string = string
    }
    if(time){
    this.node.getChildByName("label").getComponent(cc.Label).string = string
    }

    var newsonitem = this.node

    newsonitem.getComponent(cc.Mask).unscheduleAllCallbacks()
    newsonitem.heightsave = 380//newsonitem.height//高度记录
    newsonitem.height = 0
    var self = this
    self.doing = true
    newsonitem.getComponent(cc.Mask).schedule(function() {
    newsonitem.height += newsonitem.heightsave/(self.speedtimes/2)
    if(Math.abs(newsonitem.height-newsonitem.heightsave)<1){
    self.doing = true
    newsonitem.getComponent(cc.Mask).schedule(function() {
    newsonitem.height -= newsonitem.heightsave/(self.speedtimes/2)
    if(Math.abs(newsonitem.height)<1){
    self.doing = false
    }
    }, 0.01, self.speedtimes/2 -1, 1)
    }
    }, 0.01, self.speedtimes/2 -1, 0)



    },
    // update (dt) {},
    });
  • 相关阅读:
    WinForm多线程+委托防止界面假死
    C#中异步及winform中界面假死
    js如何判断当前文本的输入状态——中文输入法的那些坑
    数据库主键设计之思考
    node.js使用superagent实现模拟登陆功能(包含下载验证码功能)
    application.properties在Spring Boot项目中的位置
    ubuntu18.04安装chromium浏览器
    ubuntu 18.04安装mysql 8
    Spring Boot学习笔记——搭建一个最简单的hello world
    ubuntu 18.04安装jdk8和eclipse
  • 原文地址:https://www.cnblogs.com/luorende/p/9990897.html
Copyright © 2020-2023  润新知