1234567891011121314151617181920212223242526272829303132333435 |
- import { _decorator, Component, ImageAsset, Node, Sprite, SpriteFrame, Texture2D } from 'cc';
- const { ccclass, property } = _decorator;
- export class Tools {
- /**
- *
- * @param node
- * @param co
- */
- static clearFromParent(node: Node, co: any) {
- let arr = [];
- node.children.forEach(element => {
- if (element.getComponent(co)) {
- arr.push(element);
- }
- });
- arr.forEach((element) => {
- element.removeFromParent();
- });
- }
- /**
- *
- * @param min
- * @param max
- * @returns
- */
- public static random_between(min: number, max: number): number {
- return Math.random() * (max - min) + min;
- }
- }
|