动画背景

This commit is contained in:
2024-12-19 10:42:23 +08:00
parent 81a310b628
commit d487d985f3
12 changed files with 5244 additions and 4067 deletions

View File

@@ -0,0 +1,32 @@
import { _decorator, instantiate, Prefab } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('LuckHomeCompComp')
@ecs.register('LuckHomeComp', false)
export class LuckHomeCompComp extends CCComp {
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
}
show_bbox() {
var parent = this.node.getChildByName("bbox")
var path = "game/gui/bbox";
var prefab: Prefab = oops.res.get(path, Prefab)!;
let box = instantiate(prefab);
box.parent = parent;
this.scheduleOnce(()=>{
box.destroy();
}, 0.7)
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "461697d5-ffa2-4577-8e33-2c329f3410b5",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,50 @@
import { Texture2D } from 'cc';
import { Enum } from 'cc';
import { rect } from 'cc';
import { Sprite } from 'cc';
import { _decorator, Component } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('MoveUV')
export class MoveUV extends Component {
@property
moveSpeedX = 0;
@property
moveSpeedY = 0;
@property({ type: Enum(Texture2D.WrapMode) })
wrapMode = Texture2D.WrapMode.REPEAT;
private _sprite: Sprite;
private _rect = rect();
private _currentWrapMode: number;
getRect() {
return this._rect;
}
onLoad() {
this._sprite = this.getComponent(Sprite);
if (!this._sprite) {
let tempStr = "获取Sprite失败";
throw new Error(tempStr);
}
this._rect.set(this._sprite.spriteFrame.rect);
this._sprite.spriteFrame.packable = false;
}
update(dt: number) {
if (this._currentWrapMode !== this.wrapMode) {
this._currentWrapMode = this.wrapMode;
this._sprite.spriteFrame.texture.setWrapMode(this.wrapMode, this.wrapMode);
}
this._rect.x += this.moveSpeedX * dt;
this._rect.y += this.moveSpeedY * dt;
this._sprite.spriteFrame.rect = this._rect;
this._sprite.markForUpdateRenderData();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e399b82b-77ce-4ae0-bb2d-81ae88e3fc91",
"files": [],
"subMetas": {},
"userData": {}
}