This commit is contained in:
Lenheart 2024-03-09 13:19:32 +08:00
parent 58cdafb559
commit 74a57d671e
8 changed files with 421 additions and 107 deletions

View File

@ -12,7 +12,7 @@ export default class BaseMyAnimation extends MyAnimation {
NowSettingCount = 0;
@property({ type: CCString, displayName: '默认img路径', tooltip: "img路径" })
DefaultImgPath: string = "";
DefaultImgPath = "";
@property({ type: [CCString], displayName: 'img路径', tooltip: "img路径" })
ImgPath: string[] = Array<string>();

View File

@ -1,5 +1,5 @@
import {
_decorator, Component, math, Node, resources, Sprite, SpriteFrame, Texture2D, UITransform, v2, v3, Vec2, Vec3,
_decorator, Color, Component, math, Node, resources, Sprite, SpriteFrame, Texture2D, UITransform, v2, v3, Vec2, Vec3,
} from "cc";
import { GameState } from "../GlobalGameState/GameState";
import { ImagePack } from "../ImagePack/ImagePack";
@ -148,6 +148,16 @@ export class MyAnimation extends Component {
if (FrameObj) {
//当前帧播放时间大于本帧延迟时间时
if (this.PlayTimer > FrameObj.Delay) {
//需要初始化还原的东西
//缩放
this.node.setScale(1, 1);
//染色
this.SpriteObj.color = new Color(255, 255, 255, 255);
//帧数加1
this.NowFrame++;
//Ani播放完了
@ -159,11 +169,26 @@ export class MyAnimation extends Component {
//设置精灵对象更换图片
this.SpriteObj.spriteFrame = FrameObj.Frame;
// console.log(this.node);
//设置坐标
if (FrameObj.Pos) this.node.setPosition(FrameObj.Pos);
if (FrameObj.Flag) {
if (FrameObj.Flag.get("INTERPOLATION")) {
} else {
FrameObj.Flag.forEach((Value, Key) => {
if (Key == "RGBA") {
this.SpriteObj.color = new Color(Value[0], Value[1], Value[2], Value[3]);
}
else if (Key == "IMAGE_RATE") {
this.node.setScale(parseFloat(Value.x), parseFloat(Value.y));
}
});
}
}
//重置计时器
this.PlayTimer = 0;
}

View File

@ -1,8 +1,8 @@
import { _decorator, CCString, Component, Node, Sprite, SpriteFrame, Texture2D, UITransform, v2 } from 'cc';
import { _decorator, CCInteger, CCString, Component, Node, Sprite, SpriteFrame, Texture2D, UITransform, v2 } from 'cc';
import { MyAnimation } from './MyAnimation';
import { GameScript } from '../GameScript/GameScript';
import { ImagePack } from '../ImagePack/ImagePack';
import { ScriptAni } from '../GlobalInterface/GlobalInterface';
import { ScriptAls, ScriptAni } from '../GlobalInterface/GlobalInterface';
const { ccclass, property, requireComponent } = _decorator;
@ccclass('ScriptMyAnimation')
@ -11,7 +11,10 @@ export class ScriptMyAnimation extends MyAnimation {
@property({ type: CCString, displayName: 'Ani路径', tooltip: "Ani在PVF中的路径" })
AnimationPath: string = "";
AnimationPath = "";
// @property({ type: CCInteger, displayName: '是否显示', tooltip: "1为显示 0为不显示" })
// PlayState = 0;
//是否有替换符
Replace: Array<string>;
@ -54,12 +57,59 @@ export class ScriptMyAnimation extends MyAnimation {
});
}
Decompile_als(str: string) {
const strbuf = str.split("\n");
let Flag = 0;
let AniobjArr: Array<string> = new Array<string>;
let AniaddArr: Array<string[]> = new Array<string[]>;
strbuf.forEach((lstr, line) => {
if (Flag == 0) {
if (lstr.indexOf("[use animation]") != -1) {
Flag = 1;
} else if (lstr.indexOf("[none effect add]") != -1 || lstr.indexOf("[add]") != -1) {
Flag = 5;
}
} else if (Flag == 1) {
AniobjArr.push(lstr);
Flag = 2;
} else if (Flag == 2) {
AniobjArr.push(lstr);
Flag = 0;
} else if (Flag == 5) {
let buf = lstr.split("\t");
AniaddArr.push(buf);
Flag = 0;
}
});
let AniArr: Array<ScriptAls> = new Array<ScriptAls>;
for (let index = 0; index < AniobjArr.length; index += 2) {
let ScriptAlsBuf: ScriptAls = {};
ScriptAlsBuf.Path = AniobjArr[index];
ScriptAlsBuf.Name = AniobjArr[index + 1];
AniArr.push(ScriptAlsBuf);
}
// console.log(AniobjArr);
// console.log(AniaddArr);
return AniArr;
}
//判断是否有Als
CheckAnimotionAls() {
let Ret = GameScript.getInstance().GetDataByPath("ani/001_1x2.ani.als");
let Ret = GameScript.getInstance().GetDataByPath(this.AnimationPath + ".als");
if (Ret) {
console.log(Ret);
let Als = this.Decompile_als(Ret);
Als.forEach(aniobj => {
let NodeBuf = new Node();
// let SpriteBuf = NodeBuf.addComponent(Sprite);
let Ani = NodeBuf.addComponent(ScriptMyAnimation);
Ani.AnimationPath = this.AnimationPath.substring(0, this.AnimationPath.lastIndexOf("/") + 1) + aniobj.Path.match(/`(.*?)`/)[1].toLowerCase();
// Ani.PlayState = this.PlayState;
// console.log(Ani.AnimationPath);
this.node.parent.addChild(NodeBuf);
});
}
}

View File

@ -43,8 +43,6 @@ export class BaseButton extends Component {
start() {
//判断是否有精灵 如果没有 就给他搞一个
if (this.node.getComponent(Sprite))
this.SpriteObj = this.node.getComponent(Sprite);

View File

@ -1,4 +1,4 @@
import { _decorator, CCInteger, CCString, Component, Node, Sprite, SpriteFrame, Texture2D, v2 } from 'cc';
import { _decorator, CCInteger, CCString, Component, Node, Sprite, SpriteFrame, Texture2D, UITransform, v2 } from 'cc';
import { ImagePack } from '../ImagePack/ImagePack';
import { BaseSpriteFrame } from './BaseSpriteFrame';
const { ccclass, property } = _decorator;
@ -22,6 +22,13 @@ export class BaseSprite extends Component {
else
this.SpriteObj = this.node.addComponent(Sprite);
//设置节点锚点为左上角
this.node.getComponent(UITransform).anchorPoint = v2(0, 1);
//设置类型
this.SpriteObj.sizeMode = Sprite.SizeMode.RAW;
//设置
this.SpriteObj.trim = false;
new BaseSpriteFrame(this.ImgPath.toLocaleLowerCase(), this.ImgIndex, (_SpriteFrame) => {
this.SpriteObj.spriteFrame = _SpriteFrame;
});

View File

@ -208,14 +208,17 @@ class ScriptTree {
GlobalTool.CrcDecode(RealBuf, FileObject.Cre32);
//Ani的处理逻辑
if (Path.indexOf(".ani") != -1 && Path.indexOf(".als") == -1) {
// try {
let Buf = this.Decompile_ani(RealBuf);
this.ScriptFileData.set(Path, Buf);
return Buf;
// } catch (error) {
// console.log(Path);
// }
if (Path.indexOf(".ani") != -1) {
if (Path.indexOf(".als") != -1) {
const Ro = new ReadStream(RealBuf);
const Str = Ro.GetString();
this.ScriptFileData.set(Path, Str);
return Str;
} else {
let Buf = this.Decompile_ani(RealBuf);
this.ScriptFileData.set(Path, Buf);
return Buf;
}
}
else {
try {
@ -351,7 +354,7 @@ class ScriptTree {
for (let index = 0; index < Img_Count; index++) {
const Buf = Ro.GetInt();
//有可能Img有空路径
AniObject.Img_List.push(Ro.GetString(Buf));
AniObject.Img_List.push(Ro.GetString(Buf).toLowerCase());
}
//Ani头部标签数量

View File

@ -23,7 +23,7 @@
"_active": true,
"_components": [],
"_prefab": {
"__id__": 17
"__id__": 24
},
"_lpos": {
"__type__": "cc.Vec3",
@ -54,7 +54,7 @@
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 18
"__id__": 25
},
"_id": "f713b5ea-a70f-486c-8260-0338f089a5b8"
},
@ -77,13 +77,13 @@
"_active": true,
"_components": [
{
"__id__": 14
"__id__": 21
},
{
"__id__": 15
"__id__": 22
},
{
"__id__": 16
"__id__": 23
}
],
"_prefab": null,
@ -175,7 +175,7 @@
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 346.1673212882954,
"_orthoHeight": 300,
"_near": 0,
"_far": 1000,
"_color": {
@ -218,6 +218,9 @@
"_children": [
{
"__id__": 6
},
{
"__id__": 15
}
],
"_active": true,
@ -267,14 +270,14 @@
],
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 12
},
{
"__id__": 13
},
{
"__id__": 14
}
],
"_prefab": null,
@ -309,30 +312,28 @@
},
{
"__type__": "cc.Node",
"_name": "Test",
"_name": "Node",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 6
},
"_children": [],
"_children": [
{
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 8
},
{
"__id__": 9
},
{
"__id__": 10
"__id__": 11
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 136.281,
"y": -394.99999999999994,
"x": 406.656,
"y": -285.541,
"z": 0
},
"_lrot": {
@ -349,14 +350,101 @@
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "58nLsryTdISqQKID5Hb4CI"
"_id": "2eqXq8mlZNEo1OEHiSCz+/"
},
{
"__type__": "cc.Node",
"_name": "Button",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 7
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 10
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "3cMhmwzlJJ4qTMaShfKXN9"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 8
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "6b2rDbQKRJBI5YM2ruCZ/7"
},
{
"__type__": "227e93p2mxEV5zjvG1ofJkL",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 8
},
"_enabled": true,
"__prefab": null,
"ImgPath": "interface2/event/chn_event_2020/200922_dnf_marble/00_main.img",
"NormalImgIndex": 1,
"HoverImgIndex": 2,
"PressImgIndex": 3,
"DisableImgIndex": 4,
"_id": "b2Dl0a+fBCVb43F/u+R87a"
},
{
"__type__": "cc.UITransform",
@ -378,56 +466,7 @@
"x": 0.5,
"y": 0.5
},
"_id": "e3PWU61UNEv7dpgCI4tyOQ"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 7
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": "2fzSKdC4tJv4cl+tDLmGI9"
},
{
"__type__": "da8cbJJkjxC+qVdpm9/+8LT",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 7
},
"_enabled": true,
"__prefab": null,
"AnimationPath": "ani/001_1x2.ani",
"_id": "86S/B40YdJLqyx40ueYpvW"
"_id": "d52kwcSPVPjYkvdV5Y3yKc"
},
{
"__type__": "cc.UITransform",
@ -491,7 +530,7 @@
"_id": "0apjnJJkpLlKFaw0omFEuX"
},
{
"__type__": "9258d3QVRBC/L8BCziIBXzT",
"__type__": "a80463xbJJM5qU8FUhHK84e",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
@ -500,10 +539,202 @@
},
"_enabled": true,
"__prefab": null,
"DefaultImgPath": "sprite/interface2/event/chn_event_2020/200922_dnf_marble/00_main.img",
"GImgIndex": 0,
"PlayState": 1,
"_id": "a27U1G+TROF7ArDt28B3wZ"
"ImgPath": "interface2/event/chn_event_2020/200922_dnf_marble/00_main.img",
"ImgIndex": 0,
"_id": "63oRTrNBxMGLodUQWYSkjV"
},
{
"__type__": "cc.Node",
"_name": "touzi",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 5
},
"_children": [
{
"__id__": 16
}
],
"_active": true,
"_components": [
{
"__id__": 20
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 552.147,
"y": 198.485,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "72Pcn+hmZEIpMeO4JclUIB"
},
{
"__type__": "cc.Node",
"_name": "Test",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 15
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 17
},
{
"__id__": 18
},
{
"__id__": 19
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 646.928,
"y": 177.592,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "58nLsryTdISqQKID5Hb4CI"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "e3PWU61UNEv7dpgCI4tyOQ"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": "2fzSKdC4tJv4cl+tDLmGI9"
},
{
"__type__": "da8cbJJkjxC+qVdpm9/+8LT",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": null,
"AnimationPath": "ani/000_1x1_double.ani",
"_id": "86S/B40YdJLqyx40ueYpvW"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 15
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "7fDqoE7tdNjLdQj8L8oM8f"
},
{
"__type__": "cc.UITransform",
@ -584,28 +815,28 @@
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 19
"__id__": 26
},
"shadows": {
"__id__": 20
"__id__": 27
},
"_skybox": {
"__id__": 21
"__id__": 28
},
"fog": {
"__id__": 22
"__id__": 29
},
"octree": {
"__id__": 23
"__id__": 30
},
"skin": {
"__id__": 24
"__id__": 31
},
"lightProbeInfo": {
"__id__": 25
"__id__": 32
},
"postSettings": {
"__id__": 26
"__id__": 33
},
"bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false

View File

@ -15,7 +15,7 @@
"label": "removeSplash",
"enable": true,
"removeSplash": {
"complete": false,
"complete": true,
"form": "https://creator-api.cocos.com/api/form/show?sid=9ca4a815f78c9bcd01d30320bbf2f99b"
}
}