You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
import { _decorator, Color, Component, DynamicAtlasManager, dynamicAtlasManager, Material, Node, renderer, Sprite, tween, UIOpacity, UIRenderer, UITransform, v2, v4, Vec4 } from 'cc';
|
|
const { ccclass, property, executeInEditMode } = _decorator;
|
|
|
|
@ccclass('Hole2')
|
|
export class Hole2 extends Component {
|
|
|
|
@property({ type: Color })
|
|
color: Color = Color.WHITE;
|
|
|
|
defaultData: Vec4[] = [];
|
|
|
|
img: Sprite;
|
|
|
|
private _mt: Material;
|
|
|
|
onLoad() {
|
|
this.img = this.node.getComponent(Sprite);
|
|
this._mt = this.img.customMaterial;
|
|
}
|
|
|
|
showHole(arr: Vec4[]) {
|
|
let size = this.node.getComponent(UITransform).contentSize;
|
|
let temp = [];
|
|
for (let i = 0; i < arr.length; i++) {
|
|
let v = arr[i];
|
|
let x = (size.width / 2 + v.x) / size.width;
|
|
let y = 1 - (size.height / 2 + v.y) / size.height;
|
|
v.x = x;
|
|
v.y = y;
|
|
temp.push(v);
|
|
}
|
|
this._mt.setProperty("maskColor", this.color);
|
|
this._mt.setProperty("circles", temp);
|
|
this._mt.setProperty("textureSize", v2(size.width, size.height));
|
|
}
|
|
}
|
|
|
|
|
|
|