首页 > 其他分享 >视野(光影)实现

视野(光影)实现

时间:2023-01-30 10:22:35浏览次数:45  
标签:fillRange sub 光影 face 实现 let 视野 ._ cc

实现:
组件:cc.Sprite, ReactArc
ReactArc   const { executeInEditMode, ccclass, property } = cc._decorator;
@ccclass @executeInEditMode export default class ReactArc extends cc.Component {     @property(cc.Node)     target: cc.Node = null;
    @property     maxRange = 0.3;     @property     minRange = 0.05;
    _face: cc.Sprite = null;     get face() {         if (!this._face) {             this._face = this.getComponent(cc.Sprite);         }         return this._face;     }
    update(dt: number) {         if (CC_EDITOR) {             if (cc.isValid(this.target)) {                 let sub = this.target.position.sub(this.node.position);                 let dis = sub.mag();                 let rad = cc.v2(sub).signAngle(cc.Vec2.RIGHT);                 let deg = cc.misc.radiansToDegrees(rad) + 180;
                this.face.fillRange = (1 - (dis / 500)) * (this.maxRange - this.minRange);
                if (this.face.fillRange < 0.05) {                     this.face.fillRange = 0.05;                 }                 else if (this.face.fillRange > 0.3) {                     this.face.fillRange = 0.3;                 }                 this.face.fillStart = (-deg / 360 - this.face.fillRange / 2);
            }         }     } }  

 

 

标签:fillRange,sub,光影,face,实现,let,视野,._,cc
From: https://www.cnblogs.com/jhl289814656/p/17074665.html

相关文章