mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
3.7.4 spine不同步转3.8.1 修复3.8.1 动画
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "e15c838f-470f-4ed6-8594-6f83fda53554",
|
||||
|
@@ -39,6 +39,8 @@ export default class GAttackParabolicRemote implements GAttackBase{
|
||||
console.warn("GAttackParabolicRemote ERROR",image,bone,scale,bang);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`播放动画[GAttackParabolicRemote]`,role.nId,enemy.nId)
|
||||
|
||||
console.log(role.spine,bone);
|
||||
let bullet = GAttackBullet.create(GButtleDefault,{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "c6ed6478-8a11-42b5-ab5a-e302055e39c2",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "651f7991-f580-4d09-a013-54c78bf46740",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "a178786e-130e-4422-b7cd-1fab35d66c76",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "e6c9fc58-9fb5-4ae1-96b7-a857014d64c3",
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { sp } from "cc";
|
||||
import GFSMBase, { GFSMProcessEnum, GFSMProcessInfo, GFSMProcessMode } from "./GFSMBase";
|
||||
import GObject from "../GObject";
|
||||
import { JNFrameInfo } from "../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
|
||||
//角色动画名称枚举
|
||||
export enum GFSMBattleAminEnum {
|
||||
@@ -33,8 +34,9 @@ export abstract class GFSMAnimBase extends GFSMBase{
|
||||
//动画Root
|
||||
spine:sp.Skeleton;
|
||||
|
||||
events:{event:string,fun:Function}[] = [];
|
||||
starts:{name:string,fun:Function}[] = [];
|
||||
events:{[key:string]:Function[]}= {};
|
||||
starts:{[key:string]:Function[]}= {};
|
||||
ends:{[key:string]:Function[]}= {};
|
||||
|
||||
constructor(spine:sp.Skeleton,trackIndex:number = 0){
|
||||
super();
|
||||
@@ -42,8 +44,10 @@ export abstract class GFSMAnimBase extends GFSMBase{
|
||||
this.trackIndex = trackIndex;
|
||||
//设置监听
|
||||
this.spine.setEventListener(this.onEventListener.bind(this));
|
||||
//因为SpineBUG所以不使用Spine监听 采用自己调用
|
||||
this.spine.setStartListener(this.onStartListener.bind(this));
|
||||
//设置结束监听
|
||||
this.spine.setCompleteListener(this.onEndListener.bind(this));
|
||||
// //因为SpineBUG所以不使用Spine监听 采用自己调用
|
||||
// this.spine.setStartListener(this.onStartListener.bind(this));
|
||||
}
|
||||
|
||||
open(){
|
||||
@@ -56,49 +60,75 @@ export abstract class GFSMAnimBase extends GFSMBase{
|
||||
|
||||
//添加事件监听
|
||||
addEventListener(event:string,fun:Function){
|
||||
this.events.push({
|
||||
event,
|
||||
fun,
|
||||
})
|
||||
if(!this.events[event]) this.events[event] = [];
|
||||
this.events[event].push(fun);
|
||||
}
|
||||
|
||||
//监听动画开始播放
|
||||
addStartListener(name:string,fun:Function){
|
||||
this.starts.push({
|
||||
name,
|
||||
fun,
|
||||
})
|
||||
if(!this.starts[name]) this.starts[name] = [];
|
||||
this.starts[name].push(fun);
|
||||
}
|
||||
//监听动画结束播放
|
||||
addEndListener(name:string,fun:Function){
|
||||
if(!this.ends[name]) this.ends[name] = [];
|
||||
this.ends[name].push(fun);
|
||||
}
|
||||
|
||||
//删除事件监听
|
||||
delEventListener(event:string,fun:Function){
|
||||
if(!this.events[event]) this.events[event] = [];
|
||||
let index = this.events[event].indexOf(fun);
|
||||
if(index >= 0) this.events[event].splice(index,1)
|
||||
}
|
||||
|
||||
//删除动画开始播放
|
||||
delStartListener(name:string,fun:Function){
|
||||
if(!this.starts[name]) this.starts[name] = [];
|
||||
let index = this.starts[name].indexOf(fun);
|
||||
if(index >= 0) this.starts[name].splice(index,1)
|
||||
}
|
||||
//删除动画结束播放
|
||||
delEndListener(name:string,fun:Function){
|
||||
if(!this.ends[name]) this.ends[name] = [];
|
||||
let index = this.ends[name].indexOf(fun);
|
||||
if(index >= 0) this.ends[name].splice(index,1)
|
||||
}
|
||||
|
||||
onEventListener(entry: sp.spine.TrackEntry, ev: sp.spine.Event){
|
||||
this.events.forEach(item => {
|
||||
if(item.event == ev.data.name){
|
||||
item.fun();
|
||||
}
|
||||
if(!this.events[ev.data.name]) this.events[ev.data.name] = [];
|
||||
this.events[ev.data.name].forEach(fun => {
|
||||
fun();
|
||||
});
|
||||
}
|
||||
|
||||
onStartListener(entry: sp.spine.TrackEntry){
|
||||
this.starts.forEach(item => {
|
||||
if(entry.animation.name == item.name){
|
||||
item.fun();
|
||||
}
|
||||
if(!this.starts[entry.animation.name]) this.starts[entry.animation.name] = [];
|
||||
this.starts[entry.animation.name].forEach(fun => {
|
||||
fun();
|
||||
});
|
||||
}
|
||||
|
||||
onEndListener(entry: sp.spine.TrackEntry){
|
||||
if(!this.ends[entry.animation.name]) this.ends[entry.animation.name] = [];
|
||||
this.ends[entry.animation.name].forEach(fun => {
|
||||
fun();
|
||||
});
|
||||
}
|
||||
|
||||
// 流程图
|
||||
process: { [key: number]: GFSMProcessAnimInfo; } = {}
|
||||
|
||||
execute(process:GFSMProcessAnimInfo,dt:number){
|
||||
execute(process:GFSMProcessAnimInfo,dt:number,frame:JNFrameInfo){
|
||||
process.ifTo = process.ifTo || [];
|
||||
process.to = process.to || [];
|
||||
process.mode = GFSMProcessMode.WaitExecute;
|
||||
process.execute = this.tick.bind(this);
|
||||
super.execute(process,dt);
|
||||
super.execute(process,dt,frame);
|
||||
}
|
||||
|
||||
//-1 继续播放 0 重新执行流程 * 指定分支
|
||||
tick(dt:number,info:GFSMProcessAnimInfo){
|
||||
tick(dt:number,info:GFSMProcessAnimInfo,frame:JNFrameInfo){
|
||||
|
||||
//判断是否会切换动画 (默认不切换)
|
||||
let to = GFSMProcessEnum.Wait;
|
||||
@@ -121,8 +151,9 @@ export abstract class GFSMAnimBase extends GFSMBase{
|
||||
|
||||
//播放动画
|
||||
if(!info.track){
|
||||
console.log(`播放动画-${this.spine.getComponent(GObject).nId}-`,info);
|
||||
console.log(`${frame.index} 播放动画-${this.spine.getComponent(GObject).nId}-`,info);
|
||||
info.track = this.spine.setAnimation(this.trackIndex,info.animName,!!info.isLoop);
|
||||
this.onStartListener(info.track);
|
||||
}
|
||||
|
||||
return to;
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { JNFrameInfo } from "../../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
|
||||
//流程模式
|
||||
export enum GFSMProcessMode{
|
||||
@@ -12,7 +13,7 @@ export interface GFSMProcessInfo{
|
||||
//模式
|
||||
mode?:GFSMProcessMode;
|
||||
//执行方法
|
||||
execute?:(dt:number,info:GFSMProcessInfo) => number;
|
||||
execute?:(dt:number,info:GFSMProcessInfo,frame:JNFrameInfo) => number;
|
||||
//前往
|
||||
to?:number[];
|
||||
}
|
||||
@@ -39,14 +40,14 @@ export default class GFSMBase{
|
||||
current:number = 0;
|
||||
|
||||
//状态机刷新
|
||||
onUpdate(dt:number){
|
||||
onUpdate(dt:number,frame:JNFrameInfo){
|
||||
|
||||
if(this.isClose) return;
|
||||
|
||||
if(!this.start) this.start = 0;
|
||||
if(!this.current) this.current = 0;
|
||||
//运行流程
|
||||
this.execute(this.process[this.current],dt);
|
||||
this.execute(this.process[this.current],dt,frame);
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ export default class GFSMBase{
|
||||
}
|
||||
|
||||
//执行流程
|
||||
execute(process:GFSMProcessInfo,dt:number){
|
||||
execute(process:GFSMProcessInfo,dt:number,frame:JNFrameInfo){
|
||||
if(!process) return;
|
||||
|
||||
process.mode = process.mode || GFSMProcessMode.Execute;
|
||||
@@ -73,11 +74,11 @@ export default class GFSMBase{
|
||||
switch(process.mode){
|
||||
case GFSMProcessMode.Execute:
|
||||
//执行方法
|
||||
next = process.execute(dt,process);
|
||||
next = process.execute(dt,process,frame);
|
||||
break;
|
||||
case GFSMProcessMode.WaitExecute:
|
||||
//执行等待方法
|
||||
next = process.execute(dt,process);
|
||||
next = process.execute(dt,process,frame);
|
||||
//如果 状态 Wait 则 不重置 下一次状态从当前开始流程执行
|
||||
if(next == GFSMProcessEnum.Wait){
|
||||
isReset = false;
|
||||
@@ -93,7 +94,7 @@ export default class GFSMBase{
|
||||
if(next){
|
||||
this.current = next;
|
||||
//运行下一个流程
|
||||
this.execute(this.process[next],dt);
|
||||
this.execute(this.process[next],dt,frame);
|
||||
}else{
|
||||
if(isReset){
|
||||
//重置
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "4c6a60ae-2e26-4c45-8d64-1d7a9b32e7be",
|
||||
|
@@ -93,8 +93,8 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T){
|
||||
|
||||
//更新状态机
|
||||
this.fsm && this.fsm.onUpdate(dt / 1000);
|
||||
this.fsmAnim && this.fsmAnim.onUpdate(dt / 1000);
|
||||
this.fsm && this.fsm.onUpdate(dt / 1000,frame);
|
||||
this.fsmAnim && this.fsmAnim.onUpdate(dt / 1000,frame);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -114,6 +114,7 @@ export default class GRoleDefault extends GRoleBase<{}>{
|
||||
//攻击
|
||||
onAttack(){
|
||||
if(!this.fsm.enemy) return;
|
||||
console.log(`播放动画[${this.nId}] onAttack`,this.fsm.enemy.nId)
|
||||
//敌人扣血
|
||||
let info = TableGRoleAttack.getConfig(this.role.id);
|
||||
(new GAttack[info.attackWay]()).attack(this,info);
|
||||
|
Reference in New Issue
Block a user