再次清理英雄,切换到像素
This commit is contained in:
@@ -157,36 +157,36 @@ export class CardComp extends CCComp {
|
||||
this.do_card_bg_show(HeroInfo[uuid].quality)
|
||||
show.getChildByName("coins").active=false
|
||||
var icon_path = "game/heros/heros/"+HeroInfo[uuid].path
|
||||
resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
if (err) {
|
||||
console.error("[CardComp]: 加载骨骼数据失败:", err);
|
||||
return;
|
||||
}
|
||||
console.log("[CardComp]: 加载骨骼数据成功:", skeleton)
|
||||
// 检查节点是否仍然存在
|
||||
const maskNode = show.getChildByName("mask");
|
||||
if (!maskNode) {
|
||||
console.error("[CardComp]: mask节点不存在");
|
||||
return;
|
||||
}
|
||||
// resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
// if (err) {
|
||||
// console.error("[CardComp]: 加载骨骼数据失败:", err);
|
||||
// return;
|
||||
// }
|
||||
// console.log("[CardComp]: 加载骨骼数据成功:", skeleton)
|
||||
// // 检查节点是否仍然存在
|
||||
// const maskNode = show.getChildByName("mask");
|
||||
// if (!maskNode) {
|
||||
// console.error("[CardComp]: mask节点不存在");
|
||||
// return;
|
||||
// }
|
||||
|
||||
const heroNode = maskNode.getChildByName("hero");
|
||||
if (!heroNode) {
|
||||
console.error("[CardComp]: hero节点不存在");
|
||||
return;
|
||||
}
|
||||
// const heroNode = maskNode.getChildByName("hero");
|
||||
// if (!heroNode) {
|
||||
// console.error("[CardComp]: hero节点不存在");
|
||||
// return;
|
||||
// }
|
||||
|
||||
const spine = heroNode.getComponent(sp.Skeleton);
|
||||
if (!spine) {
|
||||
console.error("[CardComp]: hero节点上没有找到SkinnedMeshRenderer组件");
|
||||
return;
|
||||
}
|
||||
// const spine = heroNode.getComponent(sp.Skeleton);
|
||||
// if (!spine) {
|
||||
// console.error("[CardComp]: hero节点上没有找到SkinnedMeshRenderer组件");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (spine) {
|
||||
spine.skeletonData = skeleton;
|
||||
spine.setAnimation(0, "Idle", true);
|
||||
}
|
||||
});
|
||||
// if (spine) {
|
||||
// spine.skeletonData = skeleton;
|
||||
// spine.setAnimation(0, "Idle", true);
|
||||
// }
|
||||
// });
|
||||
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
// const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
|
||||
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
|
||||
|
||||
@@ -176,13 +176,17 @@ export class HeroUiComp extends CCComp {
|
||||
private loadHeroIcon(iconNode: Node, heroPath: string) {
|
||||
iconNode.parent.getChildByName("iconbg").active=false
|
||||
const icon_path = "game/heros/heros/"+heroPath
|
||||
resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
const spine = iconNode.getComponent(sp.Skeleton);
|
||||
if (spine) {
|
||||
spine.skeletonData = skeleton;
|
||||
spine.setAnimation(0, "Idle", true);
|
||||
}
|
||||
});
|
||||
// resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
// if(err) return
|
||||
// const spine = iconNode.getComponent(sp.Skeleton);
|
||||
// if (spine) {
|
||||
// spine.skeletonData = skeleton;
|
||||
// spine.setAnimation(0, "Idle", true);
|
||||
// }
|
||||
// else{
|
||||
// console.error("[HeroUiComp]: loadHeroIcon error",err)
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,94 @@
|
||||
import { _decorator, CCInteger, Component, Node } from 'cc';
|
||||
import { _decorator, CCBoolean, CCInteger, Component, Node } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('move')
|
||||
export class move extends Component {
|
||||
@property({ type: CCInteger })
|
||||
speed:number=2
|
||||
speed: number = 2;
|
||||
|
||||
@property({ type: CCInteger })
|
||||
maxX:number=640
|
||||
maxX: number = 640;
|
||||
|
||||
@property({ type: CCInteger })
|
||||
minX:number=-640
|
||||
minX: number = -640;
|
||||
|
||||
@property({ type: CCInteger })
|
||||
sc: number = 1; // 1: 从左到右, -1: 从右到左
|
||||
@property({ type: CCBoolean })
|
||||
isMove:boolean=false
|
||||
protected onLoad(): void {
|
||||
oops.message.on(GameEvent.MAP_MOVE_END_LEFT, this.onMapMoveEndLeft, this);
|
||||
oops.message.on(GameEvent.MAP_MOVE_END_RIGHT, this.onMapMoveEndRight, this);
|
||||
}
|
||||
start() {
|
||||
|
||||
// 根据移动方向设置初始位置
|
||||
}
|
||||
onMapMoveEndLeft() {
|
||||
if(this.sc==-1){
|
||||
this.isMove=true
|
||||
this.setInitialPosition()
|
||||
}
|
||||
}
|
||||
onMapMoveEndRight() {
|
||||
if(this.sc==1){
|
||||
this.isMove=true
|
||||
this.setInitialPosition()
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据移动方向设置初始位置
|
||||
*/
|
||||
setInitialPosition() {
|
||||
if (this.sc > 0) {
|
||||
// 从左到右移动,起点为 minX
|
||||
this.node.setPosition(this.minX, this.node.position.y);
|
||||
} else if (this.sc < 0) {
|
||||
// 从右到左移动,起点为 maxX
|
||||
this.node.setPosition(this.maxX, this.node.position.y);
|
||||
}
|
||||
}
|
||||
|
||||
update(dt: number) {
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed,this.node.position.y)
|
||||
if(this.node.position.x >= this.maxX){
|
||||
this.node.setPosition(this.minX,this.node.position.y)
|
||||
// 更新位置
|
||||
if(this.isMove){
|
||||
const newX = this.node.position.x + dt * this.speed * this.sc;
|
||||
this.node.setPosition(newX, this.node.position.y);
|
||||
// 检查边界并重置位置
|
||||
this.checkBoundaries();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查边界并重置位置
|
||||
*/
|
||||
checkBoundaries() {
|
||||
if (this.sc > 0) {
|
||||
// 从左到右移动,到达右边界后回到左边界
|
||||
if (this.node.position.x >= this.maxX) {
|
||||
this.node.setPosition(this.minX, this.node.position.y);
|
||||
this.isMove=false
|
||||
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_LEFT)
|
||||
}
|
||||
} else if (this.sc < 0) {
|
||||
// 从右到左移动,到达左边界后回到右边界
|
||||
if (this.node.position.x <= this.minX) {
|
||||
this.node.setPosition(this.maxX, this.node.position.y);
|
||||
this.isMove=false
|
||||
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_RIGHT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态改变移动方向
|
||||
* @param direction 1: 从左到右, -1: 从右到左
|
||||
*/
|
||||
changeDirection(direction: number) {
|
||||
this.sc = direction;
|
||||
this.setInitialPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user