修复精灵调用npk 坐标不吃问题
This commit is contained in:
parent
f30f4efabc
commit
58cdafb559
|
|
@ -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';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
|
@ -51,6 +51,13 @@ export class BaseButton extends Component {
|
|||
else
|
||||
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.HoverImgIndex, _SpriteFrame => { this.HoverImgSpriteFrame = _SpriteFrame });
|
||||
new BaseSpriteFrame(this.ImgPath, this.PressImgIndex, _SpriteFrame => { this.PressImgSpriteFrame = _SpriteFrame });
|
||||
|
|
@ -61,7 +68,6 @@ export class BaseButton extends Component {
|
|||
UploadSpriteFrame(_SpriteFrame) {
|
||||
if (this.SpriteObj.spriteFrame != _SpriteFrame) {
|
||||
this.SpriteObj.spriteFrame = _SpriteFrame;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ export class BaseSpriteFrame {
|
|||
tex.updateImage();
|
||||
this._SpriteFrame.texture = tex;
|
||||
this._SpriteFrame.offset = v2(Png.Xpos, -Png.Ypos);
|
||||
console.log(this._SpriteFrame.offset);
|
||||
|
||||
this.CallBackFunc(this._SpriteFrame);
|
||||
this.InitState = true;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ export interface ScriptAni {
|
|||
Frame: Array<Ani_Frame>; //帧对象
|
||||
}
|
||||
|
||||
//Ani结构体
|
||||
export interface ScriptAls {
|
||||
Name?: string; //Ani的名字
|
||||
Path?: string;//Ani的路径
|
||||
Layer?: Number;//图层
|
||||
FrameIndex?: Number;//开始播放帧数
|
||||
}
|
||||
|
||||
|
||||
//Pvf文件结构图
|
||||
export interface ScriptFile {
|
||||
|
|
|
|||
Loading…
Reference in New Issue