zoukankan      html  css  js  c++  java
  • 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) {},
    });
  • 相关阅读:
    微软Office团队做产品的十大经验教训 沧海
    Definitio of Business Intelligence 沧海
    爱购家园,轻松工作,轻松生活 沧海
    SAAS概述 沧海
    一定要做自己最内行的东西,一定要在自己本身的职位上来提升自己 沧海
    Android应用的构成 沧海
    管理的最高境界,就是激发每个员工的潜力。让每个员工都觉得自己的工作是一份事业。 沧海
    The life cycle of a typical project 一个典型的项目生命周期 沧海
    印度英语的特点归纳 沧海
    3G时代的移动业务赢利模式分析 沧海
  • 原文地址:https://www.cnblogs.com/luorende/p/9990897.html
Copyright © 2011-2022 走看看