parent
763cec406f
commit
33484b3406
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* @Author: WoNiu
|
* @Author: WoNiu
|
||||||
* @Date: 2024-03-23 13:22:27
|
* @Date: 2024-03-23 13:22:27
|
||||||
* @LastEditTime: 2024-03-23 16:12:16
|
* @LastEditTime: 2024-03-24 16:04:20
|
||||||
* @LastEditors: WoNiu
|
* @LastEditors: WoNiu
|
||||||
* @Description:
|
* @Description: node坐标控制
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
_decorator,
|
_decorator,
|
||||||
|
|
@ -22,6 +22,9 @@ import {
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass("LocationImportComponent")
|
@ccclass("LocationImportComponent")
|
||||||
|
/**
|
||||||
|
* @description: node坐标控制
|
||||||
|
*/
|
||||||
export class LocationImportComponent extends Component {
|
export class LocationImportComponent extends Component {
|
||||||
editBox: EditBox;
|
editBox: EditBox;
|
||||||
|
|
||||||
|
|
@ -66,6 +69,8 @@ export class LocationImportComponent extends Component {
|
||||||
textLabel.color = Color.RED;
|
textLabel.color = Color.RED;
|
||||||
textLabel.node.setPosition(0, 50);
|
textLabel.node.setPosition(0, 50);
|
||||||
textLabel.node.getComponent(UITransform).anchorPoint = v2(0, 2);
|
textLabel.node.getComponent(UITransform).anchorPoint = v2(0, 2);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update(deltaTime: number) {}
|
update(deltaTime: number) {}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* @Author: WoNiu
|
||||||
|
* @Date: 2024-03-24 16:09:55
|
||||||
|
* @LastEditTime: 2024-03-24 16:30:46
|
||||||
|
* @LastEditors: WoNiu
|
||||||
|
* @Description: 通过边框显示node的位置和大小,默认锚点(0,1)
|
||||||
|
*/
|
||||||
|
import { _decorator, Color, Component, Graphics, Node, UITransform } from 'cc';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('ShowNodeBorder')
|
||||||
|
/**
|
||||||
|
* @description: 通过边框显示node的位置和大小,默认锚点(0,1)
|
||||||
|
*/
|
||||||
|
export class ShowNodeBorder extends Component {
|
||||||
|
|
||||||
|
graphics: Graphics;
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
if(this.node.getComponent(Graphics)){
|
||||||
|
this.graphics = this.node.getComponent(Graphics);
|
||||||
|
}else{
|
||||||
|
this.graphics = this.node.addComponent(Graphics);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateBorder();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBorder() {
|
||||||
|
const borderColor = Color.YELLOW;
|
||||||
|
const borderWidth = 4;
|
||||||
|
|
||||||
|
const contentSize = this.node.getComponent(UITransform).contentSize;
|
||||||
|
|
||||||
|
this.graphics.clear();
|
||||||
|
this.graphics.strokeColor = borderColor;
|
||||||
|
this.graphics.lineWidth = borderWidth;
|
||||||
|
// this.graphics.rect(-contentSize.width / 2, -contentSize.height / 2, contentSize.width, contentSize.height);// 锚点 (0,0)
|
||||||
|
this.graphics.rect(0, 0, contentSize.width, -contentSize.height); //锚点 (0,1)
|
||||||
|
this.graphics.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
update(deltaTime: number) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "9ef9c0ff-8d63-448d-b95f-89b02e1455f3",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue