dd
This commit is contained in:
57
assets/script/game/monster/HeroCard.ts
Normal file
57
assets/script/game/monster/HeroCard.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
/*
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-11-18 17:47:56
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-08-04 15:43:04
|
||||
*/
|
||||
import { instantiate, Node, Prefab, Vec3 ,tween, v3,Collider2D,Contact2DType,PhysicsSystem2D,IPhysics2DContact, animation,Label,resources,SpriteFrame,Sprite} from "cc";
|
||||
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
|
||||
/** 角色实体 */
|
||||
@ecs.register(`HeroCard`)
|
||||
export class HeroCard extends ecs.Entity {
|
||||
// 数据层
|
||||
|
||||
// 视图层
|
||||
|
||||
|
||||
protected init() {
|
||||
// this.addComponents<ecs.Comp>(
|
||||
// MonsterModelComp);
|
||||
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
// this.remove(MonsterViewComp);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,camp:number = 1,prefab_path:string = "monster",name:string="hero") {
|
||||
// var path = "game/monster/"+prefab_path;
|
||||
var path = "game/monster/hero";
|
||||
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
||||
node.setPosition(pos)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
const url = 'game/heros/hero/'+prefab_path+'/spriteFrame';
|
||||
resources.load(url, SpriteFrame, (err: any, spriteFrame) => {
|
||||
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
|
||||
sprite.spriteFrame = spriteFrame;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
1
assets/script/game/monster/HeroCard.ts.meta
Normal file
1
assets/script/game/monster/HeroCard.ts.meta
Normal file
@@ -0,0 +1 @@
|
||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"9ec1b4da-2a40-4f23-8f9d-96f10cafb1b0","files":[],"subMetas":{},"userData":{}}
|
||||
Reference in New Issue
Block a user