46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
// Learn cc.Class:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
var ShaderMaterial = require('ShaderMaterial');
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
sp_mask: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
initdata () {
|
|
this.sp_mask._updateAssembler()
|
|
this.maxlength = this.sp_mask.node.width
|
|
this.mat = new ShaderMaterial()
|
|
this.mat.applaySpriteOnce(this.sp_mask, "Duquan", {
|
|
// plus: 1.0,
|
|
// distance: 100,
|
|
});
|
|
this.time = 0
|
|
},
|
|
|
|
update (dt) {
|
|
this.time = this.time+dt
|
|
if(this.time>1){
|
|
this.time = 0
|
|
}
|
|
var tp = this.node.width/this.maxlength*0.5
|
|
// this.mat.setParamValue('u_width', 0.17721518987341772/tp *0.002+1);
|
|
this.mat.setParamValue('u_bili', tp);
|
|
},
|
|
});
|