@ives_xxz/framework 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FW.d.ts +1845 -0
- package/FW.d.ts.meta +6 -0
- package/Framework.ts +148 -0
- package/Framework.ts.meta +10 -0
- package/README.md +93 -0
- package/README.md.meta +6 -0
- package/animation/FWAnimation.ts +13 -0
- package/animation/FWAnimation.ts.meta +10 -0
- package/animation/FWSkeleton.ts +176 -0
- package/animation/FWSkeleton.ts.meta +10 -0
- package/animation/FWTween.ts +60 -0
- package/animation/FWTween.ts.meta +10 -0
- package/animation.meta +13 -0
- package/component/FWVirtualViewComponent.ts +2080 -0
- package/component/FWVirtualViewComponent.ts.meta +10 -0
- package/component.meta +13 -0
- package/config/FWAssetConfig.ts +7 -0
- package/config/FWAssetConfig.ts.meta +10 -0
- package/config.meta +13 -0
- package/controller/FWLayerController.ts +236 -0
- package/controller/FWLayerController.ts.meta +10 -0
- package/controller.meta +13 -0
- package/data/FWData.ts +10 -0
- package/data/FWData.ts.meta +10 -0
- package/data.meta +13 -0
- package/define/FWEventDefine.ts +26 -0
- package/define/FWEventDefine.ts.meta +10 -0
- package/define/FWSystemDefine.ts +133 -0
- package/define/FWSystemDefine.ts.meta +10 -0
- package/define.meta +13 -0
- package/entry/FWEntry.ts +196 -0
- package/entry/FWEntry.ts.meta +10 -0
- package/entry.meta +13 -0
- package/expand/FWCocosExpand.ts +73 -0
- package/expand/FWCocosExpand.ts.meta +10 -0
- package/expand/FWDecorator.ts +256 -0
- package/expand/FWDecorator.ts.meta +10 -0
- package/expand/FWRollingViewNesting.ts +191 -0
- package/expand/FWRollingViewNesting.ts.meta +10 -0
- package/expand/FWTweenExpand.ts +44 -0
- package/expand/FWTweenExpand.ts.meta +10 -0
- package/expand.meta +13 -0
- package/item/FWVirtualListItem.ts +150 -0
- package/item/FWVirtualListItem.ts.meta +10 -0
- package/item.meta +13 -0
- package/language/FWLanguage.ts +69 -0
- package/language/FWLanguage.ts.meta +10 -0
- package/language/FWLanguageLabelLocalize.ts +144 -0
- package/language/FWLanguageLabelLocalize.ts.meta +10 -0
- package/language/FWLanguageSkeletonLocalize.ts +106 -0
- package/language/FWLanguageSkeletonLocalize.ts.meta +10 -0
- package/language/FWLanguageSpriteLocalize.ts +81 -0
- package/language/FWLanguageSpriteLocalize.ts.meta +10 -0
- package/language.meta +13 -0
- package/layer/FWLayer.ts +13 -0
- package/layer/FWLayer.ts.meta +10 -0
- package/layer.meta +13 -0
- package/log/FWLog.ts +115 -0
- package/log/FWLog.ts.meta +10 -0
- package/log.meta +13 -0
- package/logic/FWLogic.ts +10 -0
- package/logic/FWLogic.ts.meta +10 -0
- package/logic.meta +13 -0
- package/machine/FWAnimationMachine.ts +28 -0
- package/machine/FWAnimationMachine.ts.meta +10 -0
- package/machine/FWStateMachine.ts +75 -0
- package/machine/FWStateMachine.ts.meta +10 -0
- package/machine.meta +13 -0
- package/manager/FWAnimationManager.ts +128 -0
- package/manager/FWAnimationManager.ts.meta +10 -0
- package/manager/FWAssetManager.ts +349 -0
- package/manager/FWAssetManager.ts.meta +10 -0
- package/manager/FWAudioManager.ts +289 -0
- package/manager/FWAudioManager.ts.meta +10 -0
- package/manager/FWBundleManager.ts +91 -0
- package/manager/FWBundleManager.ts.meta +10 -0
- package/manager/FWComponentManager.ts +25 -0
- package/manager/FWComponentManager.ts.meta +10 -0
- package/manager/FWEngineManager.ts +63 -0
- package/manager/FWEngineManager.ts.meta +10 -0
- package/manager/FWEventManager.ts +275 -0
- package/manager/FWEventManager.ts.meta +10 -0
- package/manager/FWHotUpdateManager.ts +213 -0
- package/manager/FWHotUpdateManager.ts.meta +10 -0
- package/manager/FWLanguageManager.ts +116 -0
- package/manager/FWLanguageManager.ts.meta +10 -0
- package/manager/FWLayerManager.ts +490 -0
- package/manager/FWLayerManager.ts.meta +10 -0
- package/manager/FWManager.ts +8 -0
- package/manager/FWManager.ts.meta +10 -0
- package/manager/FWObjectManager.ts +91 -0
- package/manager/FWObjectManager.ts.meta +10 -0
- package/manager/FWResManager.ts +171 -0
- package/manager/FWResManager.ts.meta +10 -0
- package/manager/FWSocketManager.ts +94 -0
- package/manager/FWSocketManager.ts.meta +10 -0
- package/manager/FWStateManager.ts +102 -0
- package/manager/FWStateManager.ts.meta +10 -0
- package/manager/FWTaskManager.ts +38 -0
- package/manager/FWTaskManager.ts.meta +10 -0
- package/manager/FWTimeManager.ts +473 -0
- package/manager/FWTimeManager.ts.meta +10 -0
- package/manager/FWUiManager.ts +164 -0
- package/manager/FWUiManager.ts.meta +10 -0
- package/manager.meta +13 -0
- package/package.json +17 -0
- package/package.json.meta +6 -0
- package/scene/FWScene.ts +25 -0
- package/scene/FWScene.ts.meta +10 -0
- package/scene.meta +13 -0
- package/service/FWService.ts +7 -0
- package/service/FWService.ts.meta +10 -0
- package/service/http/FWHttp.ts +70 -0
- package/service/http/FWHttp.ts.meta +10 -0
- package/service/http.meta +13 -0
- package/service/socket/FWSocket.ts +236 -0
- package/service/socket/FWSocket.ts.meta +10 -0
- package/service/socket/FWSocketHandle.ts +17 -0
- package/service/socket/FWSocketHandle.ts.meta +10 -0
- package/service/socket/FWSocketSender.ts +16 -0
- package/service/socket/FWSocketSender.ts.meta +10 -0
- package/service/socket.meta +13 -0
- package/service.meta +13 -0
- package/state/FWState.ts +8 -0
- package/state/FWState.ts.meta +10 -0
- package/state.meta +13 -0
- package/utils/FWLodash.ts +105 -0
- package/utils/FWLodash.ts.meta +10 -0
- package/utils/FWMask.ts +222 -0
- package/utils/FWMask.ts.meta +10 -0
- package/utils/FWObject.ts +22 -0
- package/utils/FWObject.ts.meta +10 -0
- package/utils/FWObjectPool.ts +178 -0
- package/utils/FWObjectPool.ts.meta +10 -0
- package/utils/FWQueue.ts +47 -0
- package/utils/FWQueue.ts.meta +10 -0
- package/utils/FWTask.ts +223 -0
- package/utils/FWTask.ts.meta +10 -0
- package/utils.meta +13 -0
package/FW.d.ts.meta
ADDED
package/Framework.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Container, interfaces } from 'inversify';
|
|
3
|
+
import { FWSystemDefine } from './define/FWSystemDefine';
|
|
4
|
+
import FWLog from './log/FWLog';
|
|
5
|
+
import { FWEventDefine } from './define/FWEventDefine';
|
|
6
|
+
|
|
7
|
+
class Framework {
|
|
8
|
+
private container: Container;
|
|
9
|
+
private static instance: Framework;
|
|
10
|
+
private constructor() {
|
|
11
|
+
this.container = new Container({
|
|
12
|
+
defaultScope: 'Singleton',
|
|
13
|
+
autoBindInjectable: true,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initialize() {}
|
|
18
|
+
|
|
19
|
+
public static getInstance() {
|
|
20
|
+
if (!this.instance) {
|
|
21
|
+
this.instance = new Framework();
|
|
22
|
+
}
|
|
23
|
+
return this.instance;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public getContainer(): Container {
|
|
27
|
+
return this.container;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 获取组件 */
|
|
31
|
+
public getComponent<T>(serviceIdentifier: FW.ServiceIdentifier<T>): T {
|
|
32
|
+
if (typeof serviceIdentifier === 'string') {
|
|
33
|
+
if (this.container.isBound(serviceIdentifier)) {
|
|
34
|
+
return this.container.get<T>(serviceIdentifier);
|
|
35
|
+
}
|
|
36
|
+
} else if (typeof serviceIdentifier === 'function') {
|
|
37
|
+
const className = serviceIdentifier.name;
|
|
38
|
+
|
|
39
|
+
if (this.container.isBound(serviceIdentifier)) {
|
|
40
|
+
return this.container.get<T>(serviceIdentifier);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const suffixMap = {
|
|
44
|
+
Logic: FWSystemDefine.FWBindTag.LOGIC,
|
|
45
|
+
Data: FWSystemDefine.FWBindTag.DATA,
|
|
46
|
+
Config: FWSystemDefine.FWBindTag.CONFIG,
|
|
47
|
+
Sender: FWSystemDefine.FWBindTag.SENDER,
|
|
48
|
+
Handle: FWSystemDefine.FWBindTag.HANDLE,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const [suffix] = Object.entries(suffixMap).find(([key]) => className.endsWith(key)) || [];
|
|
52
|
+
|
|
53
|
+
if (suffix) {
|
|
54
|
+
const bundleName = FW.Entry.bundleName;
|
|
55
|
+
const tag = suffixMap[suffix as keyof typeof suffixMap];
|
|
56
|
+
const bindingKey = this.getKey(bundleName, tag);
|
|
57
|
+
|
|
58
|
+
if (this.container.isBound(bindingKey)) {
|
|
59
|
+
return this.container.get<T>(bindingKey);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return this.getComponents(serviceIdentifier)[0];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** 获取所有组件 */
|
|
67
|
+
public getComponents<T>(serviceIdentifier: FW.ServiceIdentifier<T>): T[] {
|
|
68
|
+
const binder = (this.container as any)._bindingDictionary;
|
|
69
|
+
const map = binder._map;
|
|
70
|
+
|
|
71
|
+
// 获取所有可能的子类绑定
|
|
72
|
+
const childBindings: interfaces.Binding<T>[] = [];
|
|
73
|
+
for (const [key, bindings] of map.entries()) {
|
|
74
|
+
for (const binding of bindings) {
|
|
75
|
+
if (this.isSubclassOf(binding.implementationType, serviceIdentifier)) {
|
|
76
|
+
childBindings.push(binding);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const instances: T[] = [];
|
|
82
|
+
for (const binding of childBindings) {
|
|
83
|
+
try {
|
|
84
|
+
const instance = this.getComponent<T>(binding.serviceIdentifier as any);
|
|
85
|
+
instances.push(instance);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
throw new Error(e);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return instances;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 注册数据
|
|
96
|
+
* @param data
|
|
97
|
+
*/
|
|
98
|
+
register(data: FW.RegisterFramework) {
|
|
99
|
+
const classes = [data.logic, data.data, data.config, data.sender, data.handle];
|
|
100
|
+
|
|
101
|
+
classes.forEach((cls, index) => {
|
|
102
|
+
if (cls && !this.container.isBound(cls)) {
|
|
103
|
+
this.container.bind(cls).toSelf().inSingletonScope();
|
|
104
|
+
this.container.bind(this.getKey(data.bundleName, index)).toService(cls);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 注销数据
|
|
110
|
+
* @param data
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
unRegister(data: FW.RegisterFramework) {
|
|
114
|
+
const classes = [data.logic, data.data, data.config, data.sender, data.handle];
|
|
115
|
+
|
|
116
|
+
classes.forEach((cls, index) => {
|
|
117
|
+
const key = this.getKey(data.bundleName, index);
|
|
118
|
+
if (cls && this.container.isBound(cls)) {
|
|
119
|
+
this.container.get(key)['onDestroy']?.();
|
|
120
|
+
this.container.unbind(cls);
|
|
121
|
+
}
|
|
122
|
+
if (this.container.isBound(key)) {
|
|
123
|
+
this.container.get(key)['onDestroy']?.();
|
|
124
|
+
this.container.unbind(this.getKey(data.bundleName, index));
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private getKey(bundleName: string, tag: FWSystemDefine.FWBindTag) {
|
|
130
|
+
return `${bundleName}${tag}`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private isSubclassOf(child: any, parent: any): boolean {
|
|
134
|
+
if (typeof child !== 'function' || typeof parent !== 'function') {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
let current = child;
|
|
138
|
+
while (current) {
|
|
139
|
+
if (current === parent) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
current = Object.getPrototypeOf(current);
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default Framework.getInstance();
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# framework
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin http://47.243.247.195:8099/crazy_client/framework.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](http://47.243.247.195:8099/crazy_client/framework/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
package/README.md.meta
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export abstract class FWAnimation {
|
|
2
|
+
/**
|
|
3
|
+
* 动画名字
|
|
4
|
+
*/
|
|
5
|
+
abstract animationName: string;
|
|
6
|
+
/**
|
|
7
|
+
* 动画对象
|
|
8
|
+
*/
|
|
9
|
+
abstract animation: cc.Tween | sp.Skeleton | cc.Animation;
|
|
10
|
+
protected abstract onInit?(): void;
|
|
11
|
+
public abstract pause?(): void;
|
|
12
|
+
public abstract resume?(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import FWLog from '../log/FWLog';
|
|
2
|
+
import { FWAnimation } from './FWAnimation';
|
|
3
|
+
|
|
4
|
+
export class FWSkeleton extends FWAnimation implements FW.Skeleton {
|
|
5
|
+
animationName: string;
|
|
6
|
+
animation: sp.Skeleton;
|
|
7
|
+
|
|
8
|
+
protected onInit() {
|
|
9
|
+
/** 开启合批 */
|
|
10
|
+
this.animation.enableBatch = true;
|
|
11
|
+
/** 关闭贴图预乘 */
|
|
12
|
+
this.animation.premultipliedAlpha = false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async play(args?: FW.SkeletonArgs): Promise<void>;
|
|
16
|
+
async play(animationName?: string, args?: FW.SkeletonArgs): Promise<void>;
|
|
17
|
+
async play(): Promise<void> {
|
|
18
|
+
let animationName: string;
|
|
19
|
+
let args: FW.SkeletonArgs;
|
|
20
|
+
|
|
21
|
+
if (arguments.length == 1) {
|
|
22
|
+
args = arguments[0];
|
|
23
|
+
} else if (arguments.length == 2) {
|
|
24
|
+
animationName = arguments[0];
|
|
25
|
+
args = arguments[1];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
this.animation.setCompleteListener(() => {
|
|
30
|
+
this.animation.setCompleteListener(null);
|
|
31
|
+
FW.Entry.animationMgr.removeSkeleton(this.animationName);
|
|
32
|
+
args?.cb?.();
|
|
33
|
+
resolve();
|
|
34
|
+
});
|
|
35
|
+
const skeletonNames = this.getAnimationNames();
|
|
36
|
+
|
|
37
|
+
animationName = animationName || skeletonNames?.[0];
|
|
38
|
+
|
|
39
|
+
if (!animationName) {
|
|
40
|
+
FWLog.warn(`not find animationName,please check:${animationName}`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!this.hasAnimation(animationName)) {
|
|
45
|
+
FWLog.warn(`not find animationName,please check:${animationName}`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const trackEntry: sp.spine.TrackEntry = this.animation.setAnimation(
|
|
50
|
+
0,
|
|
51
|
+
animationName,
|
|
52
|
+
args?.loop ?? false,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (!this.animation.isAnimationCached() && trackEntry === null) {
|
|
56
|
+
FWLog.warn('cache mode no have callback!');
|
|
57
|
+
args.cb?.();
|
|
58
|
+
resolve();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (trackEntry) {
|
|
63
|
+
trackEntry.animationStart = trackEntry.animationEnd * (args?.progress ?? 0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.animation.paused = false;
|
|
67
|
+
this.animation.timeScale = args?.timeScale ?? 1;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 设置皮肤
|
|
72
|
+
* @param skinName
|
|
73
|
+
*/
|
|
74
|
+
setSkin(skinName: string) {
|
|
75
|
+
this.animation.setSkin(skinName);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 更新数据
|
|
79
|
+
*/
|
|
80
|
+
updateSkeletonData(data: sp.SkeletonData) {
|
|
81
|
+
this.animation.skeletonData = data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 获取trackEntry
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
public getTrackEntry() {
|
|
89
|
+
return this.animation.getState().tracks[0];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 是否存在动画名
|
|
94
|
+
* @param animName
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
public hasAnimation(animName: string) {
|
|
98
|
+
return this.getAnimationNames().includes(animName);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 获取所有动画
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
public getAnimations() {
|
|
106
|
+
return this.animation.getState()?.data?.skeletonData?.animations;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 获取所有动画名字
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
public getAnimationNames(): string[] {
|
|
114
|
+
const arr = [];
|
|
115
|
+
const values = Object.values(this.getAnimations());
|
|
116
|
+
values.forEach((v) => {
|
|
117
|
+
const value = v as any;
|
|
118
|
+
arr.push(value.name);
|
|
119
|
+
});
|
|
120
|
+
return arr;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** 速度缩放 */
|
|
124
|
+
public timeScale(timeScale: number) {
|
|
125
|
+
this.animation.timeScale = timeScale;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 暂停
|
|
129
|
+
*/
|
|
130
|
+
public pause(): void {
|
|
131
|
+
this.animation.paused = true;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 恢复
|
|
135
|
+
*/
|
|
136
|
+
public resume(): void {
|
|
137
|
+
this.animation.paused = false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public addBone(boneName: string, node: cc.Node): void {
|
|
141
|
+
const boneNodes = this.getBones(boneName);
|
|
142
|
+
// 取第一个骨骼作为挂点
|
|
143
|
+
let boneNode = boneNodes[0];
|
|
144
|
+
if (!boneNode) {
|
|
145
|
+
FWLog.warn('bone node is null');
|
|
146
|
+
}
|
|
147
|
+
node.parent = boneNode;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public getBones(boneName: string): cc.Node[] {
|
|
151
|
+
const attachUtil: sp.sp.AttachUtil = this.animation['attachUtil'];
|
|
152
|
+
attachUtil.generateAttachedNodes(boneName);
|
|
153
|
+
const boneNodes = attachUtil.getAttachedNodes(boneName);
|
|
154
|
+
|
|
155
|
+
return boneNodes;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public getBoneWorldPos(boneName: string): cc.Vec3 {
|
|
159
|
+
const boneNodes = this.getBones(boneName);
|
|
160
|
+
let boneNode: cc.Node = boneNodes[0];
|
|
161
|
+
if (!boneNode) {
|
|
162
|
+
FWLog.error('boneNode is null');
|
|
163
|
+
return cc.v3(0, 0, 0);
|
|
164
|
+
}
|
|
165
|
+
return boneNode.convertToWorldSpaceAR(cc.v3(0, 0, 0));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public onBonePos(boneName: string, callBack: (position: cc.Vec3) => void) {
|
|
169
|
+
const boneNodes = this.getBones(boneName);
|
|
170
|
+
// 取第一个骨骼作为挂点
|
|
171
|
+
let boneNode = boneNodes[0];
|
|
172
|
+
boneNode.on(cc.Node.EventType.POSITION_CHANGED, () => {
|
|
173
|
+
callBack(boneNode.convertToWorldSpaceAR(cc.v3()));
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FWAnimation } from "./FWAnimation";
|
|
2
|
+
|
|
3
|
+
export class FWTween extends FWAnimation implements FW.Tween {
|
|
4
|
+
animationName: string;
|
|
5
|
+
animation: cc.Tween;
|
|
6
|
+
|
|
7
|
+
public start(): FWTween {
|
|
8
|
+
this.animation.start();
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public pause(): FWTween {
|
|
13
|
+
this.animation.pause();
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public resume(): FWTween {
|
|
18
|
+
this.animation.resume();
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public timeScale(timeScale: number): FWTween {
|
|
23
|
+
this.animation.setSpeed(timeScale);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public stop() {
|
|
28
|
+
this.animation.stop();
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public to<
|
|
33
|
+
OPTS extends Partial<{
|
|
34
|
+
progress: Function;
|
|
35
|
+
easing: Function | String;
|
|
36
|
+
onUpdate: Function;
|
|
37
|
+
}>
|
|
38
|
+
>(duration: number, props: any, opts?: OPTS) {
|
|
39
|
+
this.animation.to(duration, props, opts);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public by<
|
|
44
|
+
OPTS extends Partial<{
|
|
45
|
+
progress: Function;
|
|
46
|
+
easing: Function | String;
|
|
47
|
+
onUpdate: Function;
|
|
48
|
+
}>
|
|
49
|
+
>(duration: number, props: any, opts?: OPTS) {
|
|
50
|
+
this.animation.to(duration, props, opts);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
set(props: any) {
|
|
55
|
+
this.animation.set(props);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onInit?();
|
|
60
|
+
}
|
package/animation.meta
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ver": "1.1.3",
|
|
3
|
+
"uuid": "355cab7e-6e54-46de-8ee1-6301aa73043f",
|
|
4
|
+
"importer": "folder",
|
|
5
|
+
"isBundle": false,
|
|
6
|
+
"bundleName": "",
|
|
7
|
+
"priority": 1,
|
|
8
|
+
"compressionType": {},
|
|
9
|
+
"optimizeHotUpdate": {},
|
|
10
|
+
"inlineSpriteFrames": {},
|
|
11
|
+
"isRemoteBundle": {},
|
|
12
|
+
"subMetas": {}
|
|
13
|
+
}
|