Merge remote-tracking branch 'lin/Lenheart' into YiZiTing

This commit is contained in:
DESKTOP-J7I1C4E\a9350 2024-03-08 19:47:12 +08:00
commit 197028ccc7
3 changed files with 18 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { _decorator, CCInteger, CCString, Component, Node, Sprite, SpriteFrame, input, Input, __private, NodeEventType, EventTouch, EventMouse } from 'cc'; import { _decorator, CCInteger, CCString, Component, Node, Sprite, SpriteFrame, input, Input, __private, NodeEventType, EventTouch, EventMouse, UITransform, v2 } from 'cc';
import { BaseSpriteFrame } from './BaseSpriteFrame'; import { BaseSpriteFrame } from './BaseSpriteFrame';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ -51,6 +51,13 @@ export class BaseButton extends Component {
else else
this.SpriteObj = this.node.addComponent(Sprite); this.SpriteObj = this.node.addComponent(Sprite);
//设置节点锚点为左上角
this.node.getComponent(UITransform).anchorPoint = v2(0, 1);
//设置类型
this.SpriteObj.sizeMode = Sprite.SizeMode.RAW;
//设置
this.SpriteObj.trim = false;
new BaseSpriteFrame(this.ImgPath, this.NormalImgIndex, _SpriteFrame => { this.NormalImgSpriteFrame = _SpriteFrame }); new BaseSpriteFrame(this.ImgPath, this.NormalImgIndex, _SpriteFrame => { this.NormalImgSpriteFrame = _SpriteFrame });
new BaseSpriteFrame(this.ImgPath, this.HoverImgIndex, _SpriteFrame => { this.HoverImgSpriteFrame = _SpriteFrame }); new BaseSpriteFrame(this.ImgPath, this.HoverImgIndex, _SpriteFrame => { this.HoverImgSpriteFrame = _SpriteFrame });
new BaseSpriteFrame(this.ImgPath, this.PressImgIndex, _SpriteFrame => { this.PressImgSpriteFrame = _SpriteFrame }); new BaseSpriteFrame(this.ImgPath, this.PressImgIndex, _SpriteFrame => { this.PressImgSpriteFrame = _SpriteFrame });
@ -61,7 +68,6 @@ export class BaseButton extends Component {
UploadSpriteFrame(_SpriteFrame) { UploadSpriteFrame(_SpriteFrame) {
if (this.SpriteObj.spriteFrame != _SpriteFrame) { if (this.SpriteObj.spriteFrame != _SpriteFrame) {
this.SpriteObj.spriteFrame = _SpriteFrame; this.SpriteObj.spriteFrame = _SpriteFrame;
} }
} }

View File

@ -29,6 +29,8 @@ export class BaseSpriteFrame {
tex.updateImage(); tex.updateImage();
this._SpriteFrame.texture = tex; this._SpriteFrame.texture = tex;
this._SpriteFrame.offset = v2(Png.Xpos, -Png.Ypos); this._SpriteFrame.offset = v2(Png.Xpos, -Png.Ypos);
console.log(this._SpriteFrame.offset);
this.CallBackFunc(this._SpriteFrame); this.CallBackFunc(this._SpriteFrame);
this.InitState = true; this.InitState = true;
}); });

View File

@ -52,6 +52,14 @@ export interface ScriptAni {
Frame: Array<Ani_Frame>; //帧对象 Frame: Array<Ani_Frame>; //帧对象
} }
//Ani结构体
export interface ScriptAls {
Name?: string; //Ani的名字
Path?: string;//Ani的路径
Layer?: Number;//图层
FrameIndex?: Number;//开始播放帧数
}
//Pvf文件结构图 //Pvf文件结构图
export interface ScriptFile { export interface ScriptFile {