签名添加

/**
 * 添加签名
 * 使用方法 在初始scene里  addChild(new CoderInfo())
 */
var CoderInfo = cc.Layer.extend({
    info:"触控未来\n《什么什么》 \n4班学员甲 \nQQ 1234567\n2016-6-2",
    ctor:function(){
        this._super()
        var imgBtn = new cc.MenuItemImage('res/icon_coder.png','res/icon_coder_down.png',this.showInfo,this)
        imgBtn.scale = 0.5
        var info_menu = new cc.Menu(imgBtn)
        this.addChild(info_menu)
        info_menu.setPosition(30, cc.winSize.height-30)
        cc.textureCache.addImage("res/CK14.png");
    },
    isShowInfo:false,
    showInfo:function(){
        if(this.isShowInfo) return
        this.isShowInfo = true
        var gradient = new cc.LayerColor(cc.color(255,222,222,200));
        this.addChild(gradient);


        var param = {}
        param.minFilter = gl.LINEAR
        param.magFilter = gl.LINEAR
        param.wrapS = gl.REPEAT
        param.wrapT = gl.REPEAT
        var tex = cc.textureCache.addImage("res/CK14.png");
        tex.setTexParameters(param)
        var sp = new cc.Sprite(tex)
        sp.setTextureRect(cc.rect(0,0,cc.winSize.width, cc.winSize.height))
        sp.setPosition(cc.winSize.width>>1,cc.winSize.height>>1)
        this.addChild(sp)


        var label = new cc.LabelTTF(this.info,"Microsoft YaHei",30)
        label.enableStroke(cc.color(0,0,0,255),2)
        label.setPosition(cc.winSize.width>>1,cc.winSize.height>>1)
        this.addChild(label)


        var closeLabel = new cc.LabelTTF("3秒后自动关闭","Microsoft YaHei",20)
        closeLabel.enableStroke(cc.color(0,0,0,255),1.5)
        closeLabel.setPosition(cc.winSize.width-closeLabel.width,closeLabel.height)
        this.addChild(closeLabel)


        var that = this
        setTimeout(function(){
            that.removeChild(sp)
            that.removeChild(gradient)
            that.removeChild(label)
            that.removeChild(closeLabel)
            that.isShowInfo = false
        },3000)
    },
    onExit:function(){
        this._super()
        this.removeAllChildren(true)
    }
})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值