Commit 1cc8f2b4 authored by asdf's avatar asdf

获取骨骼真实大小

parent f0844c8f
...@@ -562,6 +562,7 @@ ...@@ -562,6 +562,7 @@
], ],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_useOriginalSize": true,
"_string": "", "_string": "",
"_N$string": "", "_N$string": "",
"_fontSize": 42, "_fontSize": 42,
......
...@@ -74,6 +74,10 @@ cc.Class({ ...@@ -74,6 +74,10 @@ cc.Class({
// imageUrl = 'http://127.0.0.1/walkingfish_tex.png'; // imageUrl = 'http://127.0.0.1/walkingfish_tex.png';
// skeUrl = 'http://127.0.0.1/walkingfish_ske.json'; // skeUrl = 'http://127.0.0.1/walkingfish_ske.json';
// atlasUrl = 'http://127.0.0.1/walkingfish_tex.json'; // atlasUrl = 'http://127.0.0.1/walkingfish_tex.json';
// imageUrl = 'http://127.0.0.1/B1U5L3_page1_ani_tex.png';
// skeUrl = 'http://127.0.0.1/B1U5L3_page1_ani_ske.json';
// atlasUrl = 'http://127.0.0.1/B1U5L3_page1_ani_tex.json';
cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => { cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
if (error) { if (error) {
console.log(error) console.log(error)
...@@ -101,6 +105,8 @@ cc.Class({ ...@@ -101,6 +105,8 @@ cc.Class({
} }
this.dragonBone.armatureName = data.name; this.dragonBone.armatureName = data.name;
this.animationName = data.animation[0].name; this.animationName = data.animation[0].name;
this.setSpineScale(data.canvas);
} }
}); });
} }
...@@ -125,19 +131,19 @@ cc.Class({ ...@@ -125,19 +131,19 @@ cc.Class({
} }
} }
}, },
setSpineScale() { setSpineScale(size) {
let bgWidth = 1000; let bgWidth = 1000;
let bgHeight = 500; let bgHeight = 500;
if (!this.data.text) { if (!this.data.text) {
bgHeight = 546; bgHeight = 546;
} }
if (this.dragonBone.node.width != bgWidth || this.dragonBone.node.height != bgHeight) { if (size.width != bgWidth || size.height != bgHeight) {
let designScale = bgWidth / bgHeight; let designScale = bgWidth / bgHeight;
let scale = this.dragonBone.node.width / this.dragonBone.node.height; let scale = size.width / size.height;
if (scale > designScale) { if (scale > designScale) {
this.dragonBone.node.scale = bgWidth / this.dragonBone.node.width; this.dragonBone.node.scale = bgWidth / size.width;
} else { } else {
this.dragonBone.node.scale = bgHeight / this.dragonBone.node.height; this.dragonBone.node.scale = bgHeight / size.height;
} }
} }
}, },
......
...@@ -138,7 +138,7 @@ cc.Class({ ...@@ -138,7 +138,7 @@ cc.Class({
}, },
getDefaultData() { getDefaultData() {
const dataJson = '{"contentObj":{"version":"1.1","key":"DataKey_Cocos_Test","haveCover":true,"dataArray":[{"type":"Image","text":"没 有 数 据","image_url":""},{"type":"Spine","text":"没 有 数 据","image_url":""}]}}' const dataJson = '{"contentObj":{"version":"1.1","key":"DataKey_Cocos_Test","haveCover":true,"dataArray":[{"type":"Spine","text":"没 有 数 据","image_url":""},{"type":"Spine","text":"没 有 数 据","image_url":""}]}}'
const data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment