• 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) {},
    });
  • 相关阅读:
    mysql数据库(1)
    通过全局异常处理机制实现接口参数校验返回指定返回类型
    http接口安全校验
    java 锁机制介绍
    通过反射获取类的所有属性值拼接成字符串工具类
    Mybatis中出现java.sql.SQLException: 无效的列类型: 1111
    判断两个Long相等
    jwt工具类
    mybatis #{}和${}的区别是什么
    报错解决NoSuchMethod。。。
  • 原文地址:https://www.cnblogs.com/luorende/p/9990897.html
Copyright © 2020-2023  润新知