@safe-engine/cocos 2.6.3 → 2.6.5
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/dist/dragonbones/DragonBonesSystem.js +3 -3
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts +19 -0
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +1 -0
- package/dist/dragonbones/PixiDragonBonesSprite.js +75 -0
- package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -1
- package/dist/dragonbones/db-cocos/CocosFactory.js +2 -1
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +1 -1
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -1
- package/dist/dragonbones/db-cocos/SimpleMeshNode.js +1 -1
- package/dist/gui/GUISystem.js +1 -1
- package/dist/gworld/components/AnimationComponent.d.ts +65 -0
- package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
- package/dist/gworld/components/AnimationComponent.js +141 -0
- package/dist/gworld/components/CollideComponent.d.ts +64 -0
- package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
- package/dist/gworld/components/CollideComponent.js +269 -0
- package/dist/gworld/components/EnhancedComponent.d.ts +22 -0
- package/dist/gworld/components/EnhancedComponent.d.ts.map +1 -0
- package/dist/gworld/components/EnhancedComponent.js +51 -0
- package/dist/gworld/components/GUIComponent.d.ts +67 -0
- package/dist/gworld/components/GUIComponent.d.ts.map +1 -0
- package/dist/gworld/components/GUIComponent.js +166 -0
- package/dist/gworld/components/NoRenderComponent.d.ts +38 -0
- package/dist/gworld/components/NoRenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/NoRenderComponent.js +81 -0
- package/dist/gworld/components/NodeComp.d.ts +152 -0
- package/dist/gworld/components/NodeComp.d.ts.map +1 -0
- package/dist/gworld/components/NodeComp.js +405 -0
- package/dist/gworld/components/RenderComponent.d.ts +58 -0
- package/dist/gworld/components/RenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/RenderComponent.js +166 -0
- package/dist/gworld/core/NodePool.d.ts +9 -0
- package/dist/gworld/core/NodePool.d.ts.map +1 -0
- package/dist/gworld/core/NodePool.js +30 -0
- package/dist/gworld/core/Scene.d.ts +5 -0
- package/dist/gworld/core/Scene.d.ts.map +1 -0
- package/dist/gworld/core/Scene.js +38 -0
- package/dist/gworld/core/decorator.d.ts +9 -0
- package/dist/gworld/core/decorator.d.ts.map +1 -0
- package/dist/gworld/core/decorator.js +43 -0
- package/dist/gworld/index.d.ts +8 -0
- package/dist/gworld/index.d.ts.map +1 -0
- package/dist/gworld/index.js +43 -0
- package/dist/gworld/systems/AnimationSystem.d.ts +6 -0
- package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
- package/dist/gworld/systems/AnimationSystem.js +30 -0
- package/dist/gworld/systems/CollideSystem.d.ts +20 -0
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
- package/dist/gworld/systems/CollideSystem.js +171 -0
- package/dist/gworld/systems/GUISystem.d.ts +15 -0
- package/dist/gworld/systems/GUISystem.d.ts.map +1 -0
- package/dist/gworld/systems/GUISystem.js +123 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts +16 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/NoRenderSystem.js +85 -0
- package/dist/gworld/systems/RenderSystem.d.ts +22 -0
- package/dist/gworld/systems/RenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/RenderSystem.js +104 -0
- package/dist/helper/NodePool.d.ts +9 -0
- package/dist/helper/NodePool.d.ts.map +1 -0
- package/dist/helper/NodePool.js +29 -0
- package/dist/helper/html-text-parser.d.ts +30 -0
- package/dist/helper/html-text-parser.d.ts.map +1 -0
- package/dist/helper/html-text-parser.js +354 -0
- package/dist/helper/index.d.ts +1 -0
- package/dist/helper/index.d.ts.map +1 -1
- package/dist/helper/index.js +1 -0
- package/dist/safex.d.ts +10 -0
- package/dist/safex.d.ts.map +1 -0
- package/dist/safex.js +25 -0
- package/dist/spine/CCSkeleton.d.ts +2 -0
- package/dist/spine/CCSkeleton.d.ts.map +1 -0
- package/dist/spine/CCSkeleton.js +344 -0
- package/dist/spine/CCSkeletonAnimation.d.ts +16 -0
- package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
- package/dist/spine/CCSkeletonAnimation.js +317 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +225 -0
- package/dist/spine/CCSkeletonTexture.d.ts +2 -0
- package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
- package/dist/spine/CCSkeletonTexture.js +62 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +281 -0
- package/dist/spine/PixiSpineSprite.d.ts +19 -0
- package/dist/spine/PixiSpineSprite.d.ts.map +1 -0
- package/dist/spine/PixiSpineSprite.js +72 -0
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Spine } from '@esotericsoftware/spine-pixi-v8';
|
|
2
|
+
import { Application, Assets } from 'pixi.js';
|
|
3
|
+
export function loadSpineAssets({ skeleton, atlas, texture }) {
|
|
4
|
+
return Assets.load([skeleton, atlas, texture]);
|
|
5
|
+
}
|
|
6
|
+
export class PixiSpineSprite extends cc.Sprite {
|
|
7
|
+
_canvas;
|
|
8
|
+
_pixiApp;
|
|
9
|
+
_texture;
|
|
10
|
+
_config;
|
|
11
|
+
_armatureDisplay;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
super();
|
|
14
|
+
super.ctor(); // always call this for compatibility with cocos2dx JS Javascript class system
|
|
15
|
+
this._canvas = document.createElement('canvas');
|
|
16
|
+
this._canvas.width = config.width || 1024;
|
|
17
|
+
this._canvas.height = config.height || 1024;
|
|
18
|
+
this._pixiApp = new Application();
|
|
19
|
+
this._pixiApp.init({
|
|
20
|
+
view: this._canvas,
|
|
21
|
+
width: this._canvas.width,
|
|
22
|
+
height: this._canvas.height,
|
|
23
|
+
backgroundAlpha: 0, // nền trong suốt
|
|
24
|
+
// transparent: true, // bắt buộc để alpha hoạt động
|
|
25
|
+
clearBeforeRender: true, // xoá trước khi vẽ frame mới
|
|
26
|
+
preserveDrawingBuffer: true, // giúp lấy ảnh từ canvas
|
|
27
|
+
antialias: true,
|
|
28
|
+
});
|
|
29
|
+
this._texture = new cc.Texture2D();
|
|
30
|
+
this._texture.initWithElement(this._canvas);
|
|
31
|
+
this._texture.handleLoadedTexture();
|
|
32
|
+
this.initWithTexture(this._texture);
|
|
33
|
+
this._config = config;
|
|
34
|
+
this._setupSpine();
|
|
35
|
+
}
|
|
36
|
+
_setupSpine() {
|
|
37
|
+
const { skeleton, atlas, loop, skin, timeScale, animationName } = this._config;
|
|
38
|
+
// console.log('_setupSpine', this._config, Assets.get(this._config.texture))
|
|
39
|
+
const display = Spine.from({ skeleton, atlas, scale: timeScale });
|
|
40
|
+
if (!display) {
|
|
41
|
+
console.error('Cannot build spine:', skeleton);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (skin) {
|
|
45
|
+
const skeletonData = display.skeleton.data;
|
|
46
|
+
const newSkin = skeletonData.findSkin(skin);
|
|
47
|
+
display.skeleton.setSkin(newSkin);
|
|
48
|
+
display.skeleton.setSlotsToSetupPose();
|
|
49
|
+
}
|
|
50
|
+
if (animationName)
|
|
51
|
+
display.state.setAnimation(0, animationName, loop);
|
|
52
|
+
display.x = this._canvas.width / 2;
|
|
53
|
+
display.y = this._canvas.height;
|
|
54
|
+
this._pixiApp.stage.addChild(display);
|
|
55
|
+
this._armatureDisplay = display;
|
|
56
|
+
}
|
|
57
|
+
updateTexture() {
|
|
58
|
+
if (this._armatureDisplay && this._pixiApp.renderer && this._texture) {
|
|
59
|
+
this._pixiApp.renderer.render(this._pixiApp.stage);
|
|
60
|
+
this._texture.initWithElement(this._canvas);
|
|
61
|
+
this._texture.handleLoadedTexture();
|
|
62
|
+
// console.log('updateTexture', this._texture.getPixelsHigh(), this._texture.getPixelsWide())
|
|
63
|
+
this.setTexture(this._texture);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
onExit() {
|
|
67
|
+
// console.log('onExit')
|
|
68
|
+
this._pixiApp.destroy(true, { children: true });
|
|
69
|
+
this._canvas.remove();
|
|
70
|
+
super.onExit();
|
|
71
|
+
}
|
|
72
|
+
}
|