36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
|
|
import { _decorator, CCInteger, CCString, Component, Node, Sprite, SpriteFrame, Texture2D, v2 } from 'cc';
|
||
|
|
import { ImagePack } from '../ImagePack/ImagePack';
|
||
|
|
import { BaseSpriteFrame } from './BaseSpriteFrame';
|
||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
|
||
|
|
@ccclass('BaseSprite')
|
||
|
|
export class BaseSprite extends Component {
|
||
|
|
|
||
|
|
@property({ type: CCString, displayName: 'img路径', tooltip: "img路径" })
|
||
|
|
ImgPath = "";
|
||
|
|
|
||
|
|
@property({ type: CCInteger, displayName: 'img编号', tooltip: "img编号" })
|
||
|
|
ImgIndex = 0;
|
||
|
|
|
||
|
|
//精灵对象
|
||
|
|
SpriteObj: Sprite;
|
||
|
|
|
||
|
|
start() {
|
||
|
|
//判断是否有精灵 如果没有 就给他搞一个
|
||
|
|
if (this.node.getComponent(Sprite))
|
||
|
|
this.SpriteObj = this.node.getComponent(Sprite);
|
||
|
|
else
|
||
|
|
this.SpriteObj = this.node.addComponent(Sprite);
|
||
|
|
|
||
|
|
new BaseSpriteFrame(this.ImgPath.toLocaleLowerCase(), this.ImgIndex, (_SpriteFrame) => {
|
||
|
|
this.SpriteObj.spriteFrame = _SpriteFrame;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
update(deltaTime: number) {
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|