Commit dd802a37 authored by 范雪寒's avatar 范雪寒

feat: test

parent 82d15fd6
{
"ver": "1.1.0",
"uuid": "c551970e-b095-45f3-9f1d-25cde8b8deb1",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -71,64 +71,64 @@ export function setSprNodeMaxLen(sprNode, maxW, maxH) { ...@@ -71,64 +71,64 @@ export function setSprNodeMaxLen(sprNode, maxW, maxH) {
} }
export function localPosTolocalPos(baseNode, targetNode) { export function localPosTolocalPos(baseNode, targetNode) {
const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)); const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y)); const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos; return localPos;
} }
export function worldPosToLocalPos(worldPos, baseNode) { export function worldPosToLocalPos(worldPos, baseNode) {
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y)); const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos; return localPos;
} }
export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) { export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
const worldRect1 = targetNode.getBoundingBoxToWorld(); const worldRect1 = targetNode.getBoundingBoxToWorld();
const worldRect2 = baseNode.getBoundingBoxToWorld(); const worldRect2 = baseNode.getBoundingBoxToWorld();
const sx = worldRect1.width / worldRect2.width; const sx = worldRect1.width / worldRect2.width;
const sy = worldRect1.height / worldRect2.height; const sy = worldRect1.height / worldRect2.height;
if (maxFlag) { if (maxFlag) {
return Math.max(sx, sy); return Math.max(sx, sy);
} else { } else {
return Math.min(sx, sy); return Math.min(sx, sy);
} }
} }
export function getDistance (start, end){ export function getDistance(start, end) {
var pos = cc.v2(start.x - end.x, start.y - end.y); var pos = cc.v2(start.x - end.x, start.y - end.y);
var dis = Math.sqrt(pos.x*pos.x + pos.y*pos.y); var dis = Math.sqrt(pos.x * pos.x + pos.y * pos.y);
return dis; return dis;
} }
export function playAudioByUrl(audio_url, cb=null) { export function playAudioByUrl(audio_url, cb = null) {
if (audio_url) { if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => { cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8); const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) { if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => { cc.audioEngine.setFinishCallback(audioId, () => {
cb(); cb();
}); });
} }
}); });
} }
} }
export function btnClickAnima(btn, time=0.15, rate=1.05) { export function btnClickAnima(btn, time = 0.15, rate = 1.05) {
btn.tmpScale = btn.scale; btn.tmpScale = btn.scale;
btn.on(cc.Node.EventType.TOUCH_START, () => { btn.on(cc.Node.EventType.TOUCH_START, () => {
cc.tween(btn) cc.tween(btn)
.to(time / 2, {scale: btn.scale * rate}) .to(time / 2, { scale: btn.scale * rate })
.start() .start()
}) })
btn.on(cc.Node.EventType.TOUCH_CANCEL, () => { btn.on(cc.Node.EventType.TOUCH_CANCEL, () => {
cc.tween(btn) cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale}) .to(time / 2, { scale: btn.tmpScale })
.start() .start()
}) })
btn.on(cc.Node.EventType.TOUCH_END, () => { btn.on(cc.Node.EventType.TOUCH_END, () => {
cc.tween(btn) cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale}) .to(time / 2, { scale: btn.tmpScale })
.start() .start()
}) })
} }
...@@ -179,7 +179,7 @@ export async function asyncDelay(time) { ...@@ -179,7 +179,7 @@ export async function asyncDelay(time) {
try { try {
cc.tween(cc.find('Canvas')) cc.tween(cc.find('Canvas'))
.delay(time) .delay(time)
.call(()=>{ .call(() => {
resolve(null); resolve(null);
}) })
.start(); .start();
...@@ -191,69 +191,69 @@ export async function asyncDelay(time) { ...@@ -191,69 +191,69 @@ export async function asyncDelay(time) {
export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJsonDataUrl }, texJsonData: { url: texJsonDataUrl }, texPngData: { url: texPngDataUrl } }) { export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJsonDataUrl }, texJsonData: { url: texJsonDataUrl }, texPngData: { url: texPngDataUrl } }) {
if (!texPngDataUrl || !texJsonDataUrl || !texPngDataUrl if (!texPngDataUrl || !texJsonDataUrl || !texPngDataUrl
|| texPngDataUrl == '' || texJsonDataUrl == '' || texPngDataUrl == '') { || texPngDataUrl == '' || texJsonDataUrl == '' || texPngDataUrl == '') {
return; return;
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (node.animaNode) { if (node.animaNode) {
node.animaNode.removeFromParent(); node.animaNode.removeFromParent();
}
const animaNode = new cc.Node();
animaNode.name = 'animaNode';
animaNode.parent = node;
animaNode.active = true;
node.animaNode = animaNode;
const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
const loadTexture = new Promise((resolve, reject) => {
cc.assetManager.loadRemote(texPngDataUrl, (error, texture) => {
if (error) {
reject(error);
} }
const animaNode = new cc.Node(); resolve(texture);
animaNode.name = 'animaNode'; });
animaNode.parent = node; });
animaNode.active = true;
node.animaNode = animaNode;
const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
const loadTexture = new Promise((resolve, reject) => {
cc.assetManager.loadRemote(texPngDataUrl, (error, texture) => {
if (error) {
reject(error);
}
resolve(texture);
});
});
const loadTexJsonData = new Promise((resolve, reject) => { const loadTexJsonData = new Promise((resolve, reject) => {
cc.assetManager.loadAny({ url: texJsonDataUrl }, (error, atlasJson) => { cc.assetManager.loadAny({ url: texJsonDataUrl }, (error, atlasJson) => {
if (error) { if (error) {
reject(error); reject(error);
} }
resolve(atlasJson); resolve(atlasJson);
}); });
}); });
const loadSkeJsonData = new Promise((resolve, reject) => { const loadSkeJsonData = new Promise((resolve, reject) => {
cc.assetManager.loadAny({ url: skeJsonDataUrl }, (error, dragonBonesJson) => { cc.assetManager.loadAny({ url: skeJsonDataUrl }, (error, dragonBonesJson) => {
if (error) { if (error) {
reject(error); reject(error);
} }
resolve(dragonBonesJson); resolve(dragonBonesJson);
}); });
}); });
Promise.all([loadTexture, loadTexJsonData, loadSkeJsonData]).then(([texture, atlasJson, dragonBonesJson]) => { Promise.all([loadTexture, loadTexJsonData, loadSkeJsonData]).then(([texture, atlasJson, dragonBonesJson]) => {
const atlas = new dragonBones.DragonBonesAtlasAsset(); const atlas: any = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = JSON.stringify(atlasJson); atlas.atlasJson = JSON.stringify(atlasJson);
atlas.texture = texture; atlas.texture = texture;
const asset = new dragonBones.DragonBonesAsset(); const asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = JSON.stringify(dragonBonesJson); asset.dragonBonesJson = JSON.stringify(dragonBonesJson);
dragonDisplay.dragonAtlasAsset = atlas; dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset; dragonDisplay.dragonAsset = asset;
let armatureNames = dragonBonesJson.armature.map(data => data.name); let armatureNames = (<any>dragonBonesJson).armature.map(data => data.name);
if (armatureNames.length > 0) { if (armatureNames.length > 0) {
dragonDisplay.armatureName = armatureNames[0]; dragonDisplay.armatureName = armatureNames[0];
} }
resolve(animaNode); resolve(animaNode);
});
}); });
});
} }
export class FireworkSettings { export class FireworkSettings {
...@@ -421,4 +421,21 @@ export function onHomeworkFinish() { ...@@ -421,4 +421,21 @@ export function onHomeworkFinish() {
} else { } else {
console.log('onHomeworkFinish'); console.log('onHomeworkFinish');
} }
}
export function buttonOnClick(button: cc.Node, callback: Function, scale = 1.1) {
button.on('click', () => {
if (button['cantClick']) {
return;
}
button['cantClick'] = true;
cc.tween(button)
.to(0.1, { scale: scale })
.to(0.1, { scale: 1.0 })
.call(() => {
button['cantClick'] = false;
callback && callback();
})
.start();
});
} }
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "526f6d1f-5d5d-4ef2-a939-1ecb34b13e3f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 223,
"height": 62,
"platformSettings": {},
"subMetas": {
"btn": {
"ver": "1.0.4",
"uuid": "c70ab431-6fdc-49a7-8a80-97d2cc6fa959",
"rawTextureUuid": "526f6d1f-5d5d-4ef2-a939-1ecb34b13e3f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 223,
"height": 62,
"rawWidth": 223,
"rawHeight": 62,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5a2e83b1-662e-4e73-9b89-8d6909e5bf28",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 127,
"height": 45,
"platformSettings": {},
"subMetas": {
"btn2": {
"ver": "1.0.4",
"uuid": "b7d32e44-5cbd-468c-b89a-3a498da3aa07",
"rawTextureUuid": "5a2e83b1-662e-4e73-9b89-8d6909e5bf28",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 127,
"height": 45,
"rawWidth": 127,
"rawHeight": 45,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ea257bdc-b502-46ac-9f89-550259e953b9",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 19,
"height": 17,
"platformSettings": {},
"subMetas": {
"check": {
"ver": "1.0.4",
"uuid": "b3a2ac48-c9d5-4a1b-9369-22e5ea65be14",
"rawTextureUuid": "ea257bdc-b502-46ac-9f89-550259e953b9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 19,
"height": 17,
"rawWidth": 19,
"rawHeight": 17,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0d1f9ff7-8d7c-43a3-8358-8add5557c04f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"platformSettings": {},
"subMetas": {
"ground": {
"ver": "1.0.4",
"uuid": "7638eb00-5a76-4010-a46b-6a840e5ffd75",
"rawTextureUuid": "0d1f9ff7-8d7c-43a3-8358-8add5557c04f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "053542d9-efe9-4b16-97c5-c335bbfdcc6e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 35,
"height": 41,
"platformSettings": {},
"subMetas": {
"lock": {
"ver": "1.0.4",
"uuid": "7d64367c-d20b-4292-93d8-b3288ce0571b",
"rawTextureUuid": "053542d9-efe9-4b16-97c5-c335bbfdcc6e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 35,
"height": 41,
"rawWidth": 35,
"rawHeight": 41,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "8c2f6759-f432-4862-a4e8-020479652a5b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 115,
"height": 115,
"platformSettings": {},
"subMetas": {
"logo": {
"ver": "1.0.4",
"uuid": "8d491d89-ddc3-436f-8504-035bf91acfe4",
"rawTextureUuid": "8c2f6759-f432-4862-a4e8-020479652a5b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 115,
"height": 115,
"rawWidth": 115,
"rawHeight": 115,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "69fd0f5f-c6a0-47ff-8d26-75f9f46dcdb9",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 33,
"height": 38,
"platformSettings": {},
"subMetas": {
"passCode": {
"ver": "1.0.4",
"uuid": "df5be773-5c1d-4e5e-beac-059c237f598f",
"rawTextureUuid": "69fd0f5f-c6a0-47ff-8d26-75f9f46dcdb9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 33,
"height": 38,
"rawWidth": 33,
"rawHeight": 38,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "1a80b694-eff9-43d9-8361-91ece3828872",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 30,
"height": 40,
"platformSettings": {},
"subMetas": {
"phone": {
"ver": "1.0.4",
"uuid": "ab859405-84e5-49a9-b678-ae593dc6a6c5",
"rawTextureUuid": "1a80b694-eff9-43d9-8361-91ece3828872",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 30,
"height": 40,
"rawWidth": 30,
"rawHeight": 40,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "9b79c2e2-5a02-4223-bea3-eef8bc65a6f0",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 15,
"height": 15,
"platformSettings": {},
"subMetas": {
"radio": {
"ver": "1.0.4",
"uuid": "d93a1096-db65-4b52-9d2a-202d3e18c521",
"rawTextureUuid": "9b79c2e2-5a02-4223-bea3-eef8bc65a6f0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 15,
"height": 15,
"rawWidth": 15,
"rawHeight": 15,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2f8e4d91-dcdb-4f4d-921e-09728912dde8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"platformSettings": {},
"subMetas": {
"sky": {
"ver": "1.0.4",
"uuid": "80b2bc09-975d-412c-b6d1-2f211f7361e6",
"rawTextureUuid": "2f8e4d91-dcdb-4f4d-921e-09728912dde8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "654eceed-edc7-4658-9dbb-89e4a8958dda",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 391,
"height": 55,
"platformSettings": {},
"subMetas": {
"textBg": {
"ver": "1.0.4",
"uuid": "54906191-18a9-4ffd-b076-215a233c0c14",
"rawTextureUuid": "654eceed-edc7-4658-9dbb-89e4a8958dda",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 391,
"height": 55,
"rawWidth": 391,
"rawHeight": 55,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "21e8629a-2b93-4843-99b1-083649a6d168",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 522,
"height": 172,
"platformSettings": {},
"subMetas": {
"tree": {
"ver": "1.0.4",
"uuid": "ba3974de-8716-4e92-8a26-45684bca247e",
"rawTextureUuid": "21e8629a-2b93-4843-99b1-083649a6d168",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 522,
"height": 172,
"rawWidth": 522,
"rawHeight": 172,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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