mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-17 19:57:23 +08:00
废弃红点组件
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "df85f52f-c354-483d-af86-9cd0b96cdc96",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import { _decorator, Enum, Label, Sprite, Vec3 } from 'cc';
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 红点位置 */
|
||||
export enum Position {
|
||||
/** 左上角 */
|
||||
TOP_LEFT,
|
||||
/** 右上角 */
|
||||
TOP_RIGHT
|
||||
}
|
||||
|
||||
Enum(Position);
|
||||
|
||||
/** 红点组件 */
|
||||
@ccclass('Badge')
|
||||
export class Badge extends Sprite {
|
||||
@property({ tooltip: '内容' })
|
||||
string: string = '6';
|
||||
|
||||
@property({ type: Position, tooltip: '位置\n 0: 左上角 \n 1: 右上角' })
|
||||
position: Position = Position.TOP_LEFT;
|
||||
// 徽标位置
|
||||
public static POSITION: Position;
|
||||
|
||||
private label: Label | null = null;
|
||||
|
||||
public get text(): string {
|
||||
return this.string;
|
||||
}
|
||||
public set text(text: string) {
|
||||
this.string = text;
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
this.label = this.node.getComponentInChildren(Label);
|
||||
this.setPosition(this.position);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置位置
|
||||
* @param position 位置
|
||||
*/
|
||||
private setPosition(position: Position) {
|
||||
const parentSize = this.node.parent!.uiTransform.contentSize;
|
||||
|
||||
switch (position) {
|
||||
case Position.TOP_LEFT: {
|
||||
const x = -parentSize.width / 2;
|
||||
const y = parentSize.height / 2;
|
||||
|
||||
this.node.setPosition(new Vec3(x, y, 0));
|
||||
break;
|
||||
}
|
||||
case Position.TOP_RIGHT: {
|
||||
const x = parentSize.width / 2;
|
||||
const y = parentSize.height / 2;
|
||||
|
||||
this.node.setPosition(new Vec3(x, y, 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文字
|
||||
* @param text 文字
|
||||
*/
|
||||
private setText(text: string) {
|
||||
if (this.label) {
|
||||
this.label.string = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bac76a30-f785-48f8-8a40-0750d050a7ea",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user