Commit 0496df09 authored by Tt's avatar Tt

play上传

parent f7576875
......@@ -29,6 +29,14 @@
"fd7RmgLjxEfpVg5SQ/evyl",
"bdlFZl0uhG97e4/Ek2uQYw",
"87jvfnhKFCQ60aEkaRjN3w",
"a5esZu+45LA5mBpvttspPD"
"a5esZu+45LA5mBpvttspPD",
"faXcAOGQ9GPrUqNLoTFOn9",
"02hIkVMcxDTbttpB2RZJpQ",
"4dTeR4zHFFU5jC6FrYn3/7",
"7cP+FtsiFD1KK2Fg50D0G+",
"10FGzgCfNHf6tO43l6EvV/",
"57QznmxKxHLb7xo3D8/Wp9",
"c6SekoNqJMYbab9bOWEvNm",
"echNDCVapE3JzZQ+DSGSM6"
]
}
#/////////////////////////////////////////////////////////////////////////////
# Fireball Projects
#/////////////////////////////////////////////////////////////////////////////
/library/
/temp/
/local/
/build/
#/////////////////////////////////////////////////////////////////////////////
# npm files
#/////////////////////////////////////////////////////////////////////////////
npm-debug.log
node_modules/
#/////////////////////////////////////////////////////////////////////////////
# Logs and databases
#/////////////////////////////////////////////////////////////////////////////
*.log
*.sql
*.sqlite
#/////////////////////////////////////////////////////////////////////////////
# files for debugger
#/////////////////////////////////////////////////////////////////////////////
*.sln
*.csproj
*.pidb
*.unityproj
*.suo
#/////////////////////////////////////////////////////////////////////////////
# OS generated files
#/////////////////////////////////////////////////////////////////////////////
.DS_Store
ehthumbs.db
Thumbs.db
#/////////////////////////////////////////////////////////////////////////////
# WebStorm files
#/////////////////////////////////////////////////////////////////////////////
.idea/
#//////////////////////////
# VS Code files
#//////////////////////////
.vscode/
{
"ver": "1.1.2",
"uuid": "2d7fba1a-8174-4ebb-b28c-d6fed89e48e3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "36abc766-60c3-40c3-965f-8232c750d9db",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "12b33c07-2bc9-42a7-9053-599eed9923e2",
"subMetas": {}
}
\ No newline at end of file
{"width":510,"imagePath":"nv_tex.png","height":624,"name":"女巫","SubTexture":[{"width":259,"y":356,"height":115,"name":"女巫/扫把","x":1},{"width":41,"y":1,"height":45,"name":"女巫/头发下","x":451},{"width":183,"y":473,"height":149,"name":"女巫/帽子下","x":1},{"width":205,"y":356,"height":134,"name":"女巫/罐子","x":262},{"width":42,"y":85,"height":39,"name":"女巫/右臂","x":451},{"width":18,"y":473,"height":10,"name":"女巫/飞虫","x":239},{"width":24,"y":473,"height":17,"name":"女巫/图层_4","x":186},{"width":79,"y":492,"height":66,"name":"女巫/领结","x":186},{"width":25,"y":473,"height":14,"name":"女巫/图层_3","x":212},{"width":10,"y":21,"height":15,"name":"女巫/图层_2","x":494},{"width":14,"y":1,"height":18,"name":"女巫/图层_1","x":494},{"width":48,"y":48,"height":35,"name":"女巫/左臂","x":451},{"width":22,"y":155,"height":19,"name":"女巫/图层_6","x":451},{"width":448,"y":1,"height":353,"name":"女巫/提交_0000_光束","x":1},{"width":34,"y":126,"height":27,"name":"女巫/shiluo","x":451}]}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "b83b3347-55ad-4386-98be-0ee9f791afbf",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "4b9bde69-24ee-48cf-bf97-4f184be1f68e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 510,
"height": 624,
"platformSettings": {},
"subMetas": {
"nv_tex": {
"ver": "1.0.4",
"uuid": "04379331-1f7b-4302-9a89-9079f30393da",
"rawTextureUuid": "4b9bde69-24ee-48cf-bf97-4f184be1f68e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": 0.5,
"trimX": 1,
"trimY": 1,
"width": 507,
"height": 621,
"rawWidth": 510,
"rawHeight": 624,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "cb9fa4ea-66ca-45af-ad31-e445c7b0ef32",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "042df0b8-33ee-47fe-a08c-b529ee599978",
"downloadMode": 0,
"duration": 7.74,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "debd6cea-1475-4d46-a5c5-02b2540f97f4",
"downloadMode": 0,
"duration": 10.944,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "1f6a1248-1578-4eb1-bdf9-4f2801c14558",
"downloadMode": 0,
"duration": 0.972,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "5559b108-5f24-4091-9a4a-3d5ca803d1fd",
"downloadMode": 0,
"duration": 1.188,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "91258ef3-e5b7-47cf-8480-be91ece6c0f9",
"downloadMode": 0,
"duration": 0.412,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "20185448-a1ca-4de2-8b37-7bf6cdfccbae",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "45471cc5-3d53-4068-99c4-591121300416",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "bbb7f5b8-6788-4f09-bb15-e32ab0dbbdcc",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "728c7d7b-fce1-464a-8045-f6c49873d688",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ac86e335-44ed-48e5-bd97-5f4ab7fa28d4",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "85a50052-bdb8-4fa7-8b04-ee33e303f16f",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "ItemTurnPage",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 0,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 473,
"height": 464
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
239,
-5,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "f6d87cfXDtLdbOObOJrWCRc",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "4f7c0520-945f-4c7c-9b51-9c012fca0299"
}
],
"textureList": [],
"pointsCount": 5,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "2449b534-ab4a-43ad-a680-ad4dcc1d3435"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "2449b534-ab4a-43ad-a680-ad4dcc1d3435",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "ItemTurnPage2",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 0,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 473,
"height": 464
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-239,
-5,
0,
0,
0,
0,
1,
-1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "f6d87cfXDtLdbOObOJrWCRc",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "4f7c0520-945f-4c7c-9b51-9c012fca0299"
}
],
"textureList": [],
"pointsCount": 5,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "320caeb2-9a8a-41b4-a87f-62d541b235fd"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "320caeb2-9a8a-41b4-a87f-62d541b235fd",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "e8bd16b0-3804-45a9-a8ca-f52c02224f55",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "57ea7c61-9b8b-498a-b024-c98ee9124beb",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "f4ede462-f8d7-4069-ba80-915611c058ca",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "b0c008bc-cf92-463b-8360-0984e13c2e4d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
cc.Class({
extends: cc.Component,
onLoad() {
this.nodeDict = {};
this.linkWidget(this.node);
},
// 遍历节点树,获取重要节点
// 节点名字以$开头的节点为重要节点,放进nodeDict中,可以直接拿到,不用拖拽绑定
// $btn为按钮类型,放进nodeDict,并且绑定按钮点击事件
// $ui为ui节点,放进nodeDict,并且上面绑定了BaseUI脚本,所以不继续遍历该节点的子节点
// $btnUI为按钮类型ui节点,放进nodeDict,并且上面绑定了BaseUI脚本,所以不继续遍历该节点的子节点,并且绑定按钮点击事件
linkWidget(node) {
let children = node.children;
for (let i = 0; i < children.length; i++) {
let nodeName = children[i].name;
if (nodeName.substring(0, 1) !== "$") {
this.linkWidget(children[i]);
continue;
}
let realName = nodeName.substring(1);
if (this.nodeDict[realName]) {
cc.error("节点名字重复!" + realName);
this.linkWidget(children[i]);
continue;
}
let isUI = false;
this.nodeDict[realName] = children[i];
if (nodeName.substring(1, 6) === "btnUI") {
children[i].on('click', this.buttonListener, this);
isUI = true;
} else if (nodeName.substring(1, 4) === "btn") {
children[i].on('click', this.buttonListener, this);
isUI = false;
} else if (nodeName.substring(1, 3) === "ui") {
isUI = true;
}
children[i].name = realName;
this.nodeDict[realName] = children[i];
if (!isUI) {
this.linkWidget(children[i]);
}
}
},
getNodeByName(name) {
return this.nodeDict[name];
},
buttonListener(button) { }
});
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "7af27a40-c9d2-4101-b894-8dff982f3985",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export const DefaultData = {
"startAudio": "http://staging-teach.cdn.ireadabc.com/1227771664f9dd7b1fe210a7736b76a0.mp3",
"endAudio": "http://staging-teach.cdn.ireadabc.com/1227771664f9dd7b1fe210a7736b76a0.mp3",
"waitAudio": "http://staging-teach.cdn.ireadabc.com/1227771664f9dd7b1fe210a7736b76a0.mp3",
"haveCover": false,
"coverType": "Image",
"coverImage": "",
"coverAudio": "",
"coverText": "",
"coverDragonBone": {
"skeJsonData": {
"url": ""
},
"texJsonData": {
"url": ""
},
"texPngData": {
"url": ""
}
},
"titleAudio": "",
"titleText": "",
"titleTextColor": "A",
"pageList": [
{
"pageType": "Image",
"pageAudio": "https://staging-teach.cdn.ireadabc.com/0e67aa701df18cbb5581ffb81ffa7836.mp3",
"pageText": "",
"pageImage": "",
"textColor": "A",
"pageDragonBone": {
"skeJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/b4fbbfdb7228802154092f714e028c2c.json",
"name": "1_ske.json"
},
"texJsonData": {
"url": "http://staging-teach.cdn.ireadabc.com/0e419cc03b5ebedcf1a5c796a2c39437.json",
"name": "1_tex.json"
},
"texPngData": {
"url": "http://staging-teach.cdn.ireadabc.com/b69d4cccd46630d1d144ae1abfa66bdb.png",
"name": "1_tex.png"
}
}
},
{
"pageType": "Image",
"pageAudio": "https://staging-teach.cdn.ireadabc.com/4c0379bc0f3bd0722874b2e11fb35336.mp3",
"pageText": "",
"pageImage": "",
"textColor": "A",
"pageDragonBone": {
"skeJsonData": {
"url": "https://staging-teach.cdn.ireadabc.com/d4d848c9a32e3296cfa1bacb22753ea9.json",
"name": "OP_SB1_459612_U1L4_22(1)_ske.json"
},
"texJsonData": {
"url": "https://staging-teach.cdn.ireadabc.com/4c06cdcf08b155ecc47f2236ad6e7cc2.json",
"name": "OP_SB1_459612_U1L4_22(1)_tex.json"
},
"texPngData": {
"url": "https://staging-teach.cdn.ireadabc.com/d244e99b4376dc91e069a3f22b965051.png",
"name": "OP_SB1_459612_U1L4_22(1)_tex.png"
}
}
},
{
"pageType": "Image",
"pageAudio": "https://staging-teach.cdn.ireadabc.com/fe226bc303f03ea994cb9a93d1620284.mp3",
"pageText": "",
"pageImage": "",
"textColor": "A",
"pageDragonBone": {
"skeJsonData": {
"url": "https://staging-teach.cdn.ireadabc.com/727efd64e18fe99cdfc78b801c0c93b6.json",
"name": "OP_SB1_459612_U1L4_24(1)_ske.json"
},
"texJsonData": {
"url": "https://staging-teach.cdn.ireadabc.com/6997187f2b4a787a48fee73abb90e95d.json",
"name": "OP_SB1_459612_U1L4_24(1)_tex.json"
},
"texPngData": {
"url": "https://staging-teach.cdn.ireadabc.com/23eaa25a8c7d6a29c775f3ad6adddbf9.png",
"name": "OP_SB1_459612_U1L4_24(1)_tex.png"
}
}
},
{
"pageType": "Image",
"pageAudio": "https://staging-teach.cdn.ireadabc.com/2990d622ec2940841a0741d7b64a3c50.mp3",
"pageText": "",
"pageImage": "",
"textColor": "A",
"pageDragonBone": {
"skeJsonData": {
"url": "https://staging-teach.cdn.ireadabc.com/11afe1cee9c37fcfe26af6496ddfe21a.json",
"name": "OP_SB1_459612_U1L4_26(1)_ske.json"
},
"texJsonData": {
"url": "https://staging-teach.cdn.ireadabc.com/06d1ce99efc8268a582419bde11671b1.json",
"name": "OP_SB1_459612_U1L4_26(1)_tex.json"
},
"texPngData": {
"url": "https://staging-teach.cdn.ireadabc.com/e315f97f50ed6698dee354c6d5290da5.png",
"name": "OP_SB1_459612_U1L4_26(1)_tex.png"
}
}
}
]
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "6fa9c94a-d3df-4f14-bf6b-b6aa701eb398",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
/**
* 事件模块
* onfire.js
*
*/
interface Listener {
cb: Function;
once: boolean;
target: object;
}
interface EventsType {
[eventName: string]: Listener[];
}
class EventMgr {
// 所有事件的监听器
es: EventsType = {};
on(eventName: string, cb: Function, target: object) {
if (!this.es[eventName]) {
this.es[eventName] = [];
}
this.es[eventName].push({
cb,
once: false,
target,
});
}
once(eventName: string, cb: Function, target: object) {
if (!this.es[eventName]) {
this.es[eventName] = [];
}
this.es[eventName].push({
cb,
once: true,
target,
});
}
emit(eventName: string, params?: any) {
const listeners = this.es[eventName] || [];
let l = listeners.length;
for (let i = 0; i < l; i++) {
const { cb, once, target } = listeners[i];
let args = [eventName, params];
cb.apply(target, args);
if (once) {
listeners.splice(i, 1);
i--;
l--;
}
}
}
off(eventName?: string, cb?: Function, target?: object) {
// clean all
if (eventName === undefined) {
this.es = {};
} else {
if (cb === undefined) {
// clean the eventName's listeners
delete this.es[eventName];
} else if (cb === null) {
if (!target) {
return;
}
const listeners = this.es[eventName] || [];
// clean the event and listener
let l = listeners.length;
for (let i = 0; i < l; i++) {
if (listeners[i].target === target) {
listeners.splice(i, 1);
i--;
l--;
}
}
} else {
const listeners = this.es[eventName] || [];
// clean the event and listener
let l = listeners.length;
for (let i = 0; i < l; i++) {
if (listeners[i].cb === cb && listeners[i].target === target) {
listeners.splice(i, 1);
i--;
l--;
}
}
}
}
}
}
export default new EventMgr();
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "f25d28c5-2fa1-4bfc-ab0c-9f8e3e8ff631",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const { loadSpine } = require('./utils');
const colorMap = {
"A": ["#1f356b", "#ffffff", "#bd2c37"],
"B": ["#fff8d0", "#000000", "#ffb93b"]
}
cc.Class({
extends: require('BaseUI'),
properties: {
dragonBone: dragonBones.ArmatureDisplay,
skeleton: sp.Skeleton
},
onLoad() {
this._super();
this.sprImage = this.nodeDict.sprImage.getComponent(cc.Sprite);
this.labText = this.nodeDict.labText.getComponent(cc.RichText);
this.labTextTitle = this.nodeDict.labTextTitle.getComponent(cc.RichText);
},
init(data, isCover, pageIndex) {
return new Promise((resolve, reject) => {
this.data = data;
this.data.pageType = "spine"
this.pageIndex = pageIndex;
this.isCover = isCover;
this.labText.string = '';
this.labTextTitle.string = '';
if (this.data.pageDragonBone.animType == 'spine') {
this.loadSpineAnim().then(() => {
resolve('');
})
} else {
this.loadDragonBoneAnim().then(() => {
resolve('');
})
}
});
},
playSpine() {
return new Promise((resolve, reject) => {
if (this.data.pageDragonBone.animType == 'spine') {
const skeleton = this.skeleton;
skeleton.setToSetupPose();
setTimeout(() => {
skeleton.setAnimation(0, this.animationName, false);
skeleton.setCompleteListener(() => {
GameData.isPlaying = false;
resolve('');
})
}, 1);
} else {
this.dragonBone.playAnimation(this.animationName, 1);
this.dragonBone.on(dragonBones.EventObject.COMPLETE, (evt) => {
GameData.isPlaying = false;
resolve('');
});
}
});
},
playAudio() {
if (this.data.pageAudio) {
cc.assetManager.loadRemote(this.data.pageAudio, null, (err, clip) => {
this.audioID = cc.audioEngine.play(clip, false, 1);
this.audioDuration = cc.audioEngine.getDuration(this.audioID);
});
}
},
stopAudio() {
cc.audioEngine.stop(this.audioID);
this.unschedule(this.chengeTextColor);
GameData.isPlaying = false;
},
loadBg() {
let url = this.data.pageImage;
if (!url) return;
cc.assetManager.loadRemote(url, (error, texture) => {
if (error) {
console.log(error)
}
this.sprImage.spriteFrame = new cc.SpriteFrame(texture);
this.setBgScale();
})
},
loadSpineAnim() {
return new Promise((resolve, reject) => {
const tex = this.data.pageDragonBone.texPngData.url;
const atlas = this.data.pageDragonBone.texJsonData.url;
const ske = this.data.pageDragonBone.skeJsonData.url;
loadSpine(this.skeleton, this.data.pageDragonBone.texPngData.name, {tex, atlas, ske}).then(({width, height}) => {
this.skeleton.node.width = width;
this.skeleton.node.height = height;
resolve('');
this.animationName = this.skeleton.animationNames[0];
console.log('width: ', this.skeleton.node.width);
console.log('height~~~: ', this.skeleton.node.height);
console.log('this.skeleton.node: ', this.skeleton.node);
this.setSpineScale(this.skeleton.node, this.skeleton.node);
})
});
},
loadDragonBoneAnim() {
return new Promise((resolve, reject) => {
var imageUrl = this.data.pageDragonBone.texPngData.url;
var skeUrl = this.data.pageDragonBone.skeJsonData.url;
var atlasUrl = this.data.pageDragonBone.texJsonData.url;
cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
if (error) return resolve('');
if (imageUrl == '') console.log(this.data)
cc.assetManager.loadRemote(imageUrl, (error, texture) => {
if (error) return resolve('');
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas._uuid = atlasUrl;
atlas.atlasJson = assets[0];
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset._uuid = skeUrl;
asset.dragonBonesJson = assets[1];
this.dragonBone.dragonAtlasAsset = atlas;
this.dragonBone.dragonAsset = asset;
let data = asset._dragonBonesJsonData.armature[0];
if (!data) return resolve('');
this.dragonBone.armatureName = data.name;
this.animationName = data.animation[0].name;
this.dragonBone.animationName = this.animationName;
// this.dragonBone.premultipliedAlpha = true;
// atlas.texture.setPremultiplyAlpha(true);
console.log('data.canvas:', data.canvas);
this.setSpineScale(data.canvas, this.dragonBone.node);
return resolve('');
});
});
});
},
// 缩放
setBgScale() {
let bgWidth = 382;
let bgHeight = 540;
if (this.nodeDict.sprImage.width != bgWidth || this.nodeDict.sprImage.height != bgHeight) {
let designScale = bgWidth / bgHeight;
let scale = this.nodeDict.sprImage.width / this.nodeDict.sprImage.height;
if (scale > designScale) {
this.nodeDict.sprImage.scale = bgWidth / this.nodeDict.sprImage.width;
} else {
this.nodeDict.sprImage.scale = bgHeight / this.nodeDict.sprImage.height;
}
}
},
setSpineScale(size, node) {
// return;
if (!size) {
return;
}
let bgWidth = 482;
let bgHeight = 489;
if (size.width != bgWidth || size.height != bgHeight) {
let designScale = bgWidth / bgHeight;
let scale = size.width / size.height;
if (scale > designScale) {
node.scale = bgWidth / size.width;
} else {
node.scale = bgHeight / size.height;
}
}
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "9bf56932-9f61-4b9f-b43c-ec75c1c51c01",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const FitType = {
Scale: 0,//等比缩放,一般用于背景图
FullScreen: 1,//铺满全屏,拉伸
FitMode: 2,//更改canvas适配策略,只能挂在canvas上
FullHeight: 3,
FullWidth: 4,
};
const designSize = cc.size(1280, 720);
cc.Class({
extends: cc.Component,
properties: {
FitType: {
type: cc.Enum(FitType),
default: 0
},
},
onLoad: function () {
cc.view.on('canvas-resize', this.refreshFit, this)
this.refreshFit();
},
onDestroy(){
cc.view.off('canvas-resize', this.refreshFit, this)
},
refreshFit() {
if (this.FitType == FitType.Scale) {
let winSize = cc.view.getVisibleSize();
console.log(winSize)
console.log(this.node.width,this.node.height)
if(this.node.width >= winSize.width && this.node.height >= winSize.height ){
return;
}
let scale1 = winSize.width / this.node.width;
let scale2 = winSize.height / this.node.height;
if (scale1 > scale2) {
this.node.scale = scale1;
} else {
this.node.scale = scale2;
}
} else if (this.FitType == FitType.FullScreen) {
let visiblesize = cc.view.getVisibleSize();
this.node.width = visiblesize.width;
this.node.height = visiblesize.height;
} else if (this.FitType == FitType.FullHeight) {
let visiblesize = cc.view.getVisibleSize();
let scale = visiblesize.width / this.node.width;
this.node.width = scale * this.node.width;
this.node.height = scale * this.node.height;
} else if (this.FitType == FitType.FullWidth) {
let visiblesize = cc.view.getVisibleSize();
let scale = visiblesize.height / this.node.height;
this.node.width = scale * this.node.width;
this.node.height = scale * this.node.height;
} else {
let wsize = cc.view.getFrameSize();
let scaleW = wsize.width / designSize.width;
let scaleH = wsize.height / designSize.height;
let pCanvas = this.node.getComponent(cc.Canvas);
if (pCanvas) {
if (scaleW > scaleH) { //更宽了要fitHeight, 否则height就留黑边了;
pCanvas.fitHeight = true;
pCanvas.fitWidth = false;
} else { //更高;
pCanvas.fitHeight = false;
pCanvas.fitWidth = true;
}
} else {
console.error("fitmode模式只能用在canvas节点上");
}
}
},
});
{
"ver": "1.0.8",
"uuid": "e22e1d5e-d025-463d-a8df-85de258d791e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import PageEffectAssemblerBase from "./page_effect_assembler_base";
const gfx = cc.gfx;
let vfmtPosUvColorFront = new gfx.VertexFormat([
{ name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 2 },
{ name: gfx.ATTR_UV0, type: gfx.ATTR_TYPE_FLOAT32, num: 2 },
{ name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_UINT8, num: 4, normalize: true },
{ name: "a_isFront", type: gfx.ATTR_TYPE_FLOAT32, num: 1},
]);
export default class BezierAssembler extends PageEffectAssemblerBase {
protected angle:number = 0
public updateRenderData (comp: any) {
if (comp) {
let pointNum: number = comp.getPointCount()
if (pointNum < 2) {
return
}
let node = comp.node
let height = node.height
let width = node.width
// 左下角的坐标
let posX = - width * node.anchorX
let posY = - height * node.anchorY
// 根据角度获得控制点的位置
let ctrlPosData = this._getCtrlPosByAngle(width)
let startPos = ctrlPosData.startPos
let endPos = ctrlPosData.endPos
let ctrlPos1 = ctrlPosData.ctrlPos1
let ctrlPos2 = ctrlPosData.ctrlPos2
// 记录各个顶点的位置
let bezierPosList: cc.Vec2[] = []
bezierPosList[0] = startPos
// 当前所有顶点连线的总长
let realWidth = 0
// 上一个点的纹理坐标
let lastU = 0
// 下一个点的纹理坐标
let nextU = 0
let floatsPerVert = this.floatsPerVert;
let verts = this.renderData.vDatas[0];
// 写verts时的下标
let dstOffset = 0;
for (let i = 1; i < pointNum; i++) {
let isTail = i === pointNum - 1
let lastBezierPos = bezierPosList[i - 1]
let nextBezierPos = this._getBezierPos(i / (pointNum - 1) , startPos, endPos, ctrlPos1, ctrlPos2)
let fixedData = this._fixWidth(lastBezierPos, nextBezierPos, width, realWidth, isTail)
let gapWidth = fixedData.gapWidth
nextBezierPos = fixedData.nextBezierPos
realWidth += gapWidth
bezierPosList[i] = nextBezierPos
// 根据当前小矩形的宽度占总长度的比例来计算纹理坐标的间隔
let gapU = gapWidth / width
nextU = lastU + gapU
/*
分别计算小矩形四个顶点的坐标和纹理坐标
各顶点的坐标计算方法为在左下角坐标的基础上加上顶点在贝塞尔曲线上的坐标,如果是书页顶部的顶点则还要加上书页的高度
*/
// 将4个顶点数据写入verts
dstOffset = floatsPerVert * (i-1) * 4;
verts[dstOffset] = posX + lastBezierPos.x;
verts[dstOffset + 1] = posY + lastBezierPos.y;
verts[dstOffset + 2] = lastU;
verts[dstOffset + 3] = 1;
dstOffset += floatsPerVert;
verts[dstOffset] = posX + nextBezierPos.x;
verts[dstOffset + 1] = posY + nextBezierPos.y;
verts[dstOffset + 2] = nextU;
verts[dstOffset + 3] = 1;
dstOffset += floatsPerVert;
verts[dstOffset] = posX + lastBezierPos.x;
verts[dstOffset + 1] = posY + height + lastBezierPos.y;
verts[dstOffset + 2] = lastU;
verts[dstOffset + 3] = 0;
dstOffset += floatsPerVert;
verts[dstOffset] = posX + nextBezierPos.x;
verts[dstOffset + 1] = posY + height + nextBezierPos.y;
verts[dstOffset + 2] = nextU;
verts[dstOffset + 3] = 0;
lastU = nextU
}
this.updateColor(comp, null);
this.updateIsFront(comp, 5);
}
}
init(comp: cc.RenderComponent) {
super.init(comp);
//@ts-ignore
let segmentCount = comp.getPointCount() - 1;
this.verticesCount = 4 * segmentCount;
this.indicesCount = 6 * segmentCount;
this.floatsPerVert = 6;
this.initData();
}
getVfmt() {
return vfmtPosUvColorFront;
}
private _getCtrlPosByAngle(width: number): {startPos: cc.Vec2, endPos: cc.Vec2, ctrlPos1: cc.Vec2, ctrlPos2: cc.Vec2} {
let startPos = new cc.Vec2(0, 0)
let endPos = null
let ctrlPos1 = null
let ctrlPos2 = null
let rad = this.angle * Math.PI / 180
let per = rad * 2 / Math.PI
if(this.angle <= 90) {
// 终点的x坐标变换 width => 0,速度先慢后快,使用InCubic缓动函数
let endPosX = width * (1 - Math.pow(per, 3))
// InCubic
// 终点的y坐标变换 0 => width / 4, 速度先快后慢,使用OutQuart缓动函数
let endPosY = width / 4 * (1 - Math.pow(1 - per, 4))
endPos = new cc.Vec2(endPosX, endPosY)
// 中间两个控制点坐标匀速变换
// x坐标 width => width * 3 / 4
let ctrlPosX = width * (1 - 1 / 4 * per)
// 控制点1y坐标 0 => width / 16
let ctrlPos1Y = width * 1 / 16 * per
// 控制点2y坐标 0 => width * 3 / 16
let ctrlPos2Y = width * 3 / 16 * per
ctrlPos1 = new cc.Vec2(ctrlPosX, ctrlPos1Y)
ctrlPos2 = new cc.Vec2(ctrlPosX, ctrlPos2Y)
} else {
per = per - 1
// 终点的x坐标变换 0 => width,速度先快后慢,使用OutCubic缓动函数
let endPosX = - width * (1 - Math.pow(1 - per, 3))
// 终点的y坐标变换 width / 4 => 0, 速度先慢后快,使用InQuart缓动函数
let endPosY = width / 4 * (1 - Math.pow(per, 4))
endPos = new cc.Vec2(endPosX, endPosY)
// 控制点1x坐标 width * 3 / 4 => 0
let ctrlPos1X = width * 3 / 4 * (1 - per)
// 控制点2x坐标 width * 3 / 4 => 0
let ctrlPos2X = width * 3 / 4 * Math.pow(1 - per, 3)
// 控制点1y坐标 width / 16 => 0
let ctrlPos1Y = width * 1 / 16 * (1 - per)
// 控制点2y坐标 width * 3 / 16 => 0
let ctrlPos2Y = width * 3 / 16 * (1 - Math.pow(per, 4))
ctrlPos1 = new cc.Vec2(ctrlPos1X, ctrlPos1Y)
ctrlPos2 = new cc.Vec2(ctrlPos2X, ctrlPos2Y)
}
return {
startPos: startPos,
endPos: endPos,
ctrlPos1: ctrlPos1,
ctrlPos2: ctrlPos2
}
}
// 修正宽度
private _fixWidth(lastBezierPos: cc.Vec2, nextBezierPos: cc.Vec2, width: number, realWidth: number, isTail: boolean) {
let deltaVector = nextBezierPos.sub(lastBezierPos)
// 两个顶点的间距
let gapWidth = deltaVector.mag()
// 当前的总长
let curWidth = realWidth + gapWidth
if(isTail) {
// 如果是最后一个顶点则将总长度修正至书页的真实宽度
gapWidth = width - realWidth
let direction = deltaVector.normalize()
nextBezierPos = lastBezierPos.add(direction.mul(gapWidth))
} else if(curWidth >= width) {
// 如果当前总长超过了书页的真实宽度,就衰减超过部分的1.1倍
let delta = curWidth - width
gapWidth = gapWidth - delta * 1.1
gapWidth = Math.max(0, gapWidth)
let direction = deltaVector.normalize()
nextBezierPos = lastBezierPos.add(direction.mul(gapWidth))
}
return {
gapWidth: gapWidth,
nextBezierPos: nextBezierPos,
}
}
// 贝塞尔曲线公式
private _getBezierPos(t: number, startPos: cc.Vec2, endPos: cc.Vec2, ctrlPos1: cc.Vec2, ctrlPos2: cc.Vec2): cc.Vec2 {
startPos = startPos.mul(Math.pow(1 - t, 3))
ctrlPos1 = ctrlPos1.mul(3 * t * Math.pow(1 - t, 2))
ctrlPos2 = ctrlPos2.mul(3 * (1 - t) * Math.pow(t, 2))
endPos = endPos.mul(Math.pow(t, 3))
return startPos.add(ctrlPos1.add(ctrlPos2.add(endPos)))
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "83a3b6ed-85cc-4f0c-831c-02a1bed48636",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import BezierAssembler from "./bezier_assembler";
const {ccclass, property} = cc._decorator;
@ccclass
export default class BezierRender extends cc.RenderComponent {
@property({type: [cc.Texture2D], displayName: "纹理"})
public textureList: cc.Texture2D[] = []
@property({displayName: "每条边上的顶点数量"})
public pointsCount: number = 10
protected _initedMaterial: boolean = false
onEnable () {
super.onEnable();
this.init();
}
public init() {
if (!this._initedMaterial) {
this.updateMaterial()
}
this.setVertsDirty()
}
public _resetAssembler() {
let assembler = this._assembler = new BezierAssembler()
assembler.init(this)
}
protected _updateMaterial() {
let material = this.getMaterial(0)
if (material) {
material.define('CC_USE_MODEL', 1);
if (this.textureList.length === 2) {
material.setProperty('texture0', this.textureList[0]);
material.setProperty('texture1', this.textureList[1]);
}
}
}
protected updateMaterial () {
if (this.textureList.length === 2) {
this._updateMaterial()
this._initedMaterial = true
return
}
}
public getPointCount() {
return this.pointsCount
}
public updateAngle(angle: number) {
if(!this._assembler) {
return
}
this._assembler.angle = angle;
this._assembler.updateRenderData(this);
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "f6d8771f-5c3b-4b75-b38e-6ce26b58245c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
cc.Class({
extends: cc.Component,
start () {
},
doCapture(nodeCapture,isTurn) {
let nodeCamera = new cc.Node();
nodeCamera.parent = cc.find("Canvas");
let camera = nodeCamera.addComponent(cc.Camera);
let position = nodeCapture.getPosition();
let width = nodeCapture.width;
let height = nodeCapture.height;
if(isTurn){
nodeCapture.scaleX = -1;
}
// 当 alignWithScreen 为 true 的时候,摄像机会自动将视窗大小调整为整个屏幕的大小。如果想要完全自由地控制摄像机,则需要将 alignWithScreen 设置为 false。(v2.2.1 新增)
camera.alignWithScreen = false;
// 设置摄像机的投影模式是正交(true)还是透视(false)模式
camera.ortho = true;
// 摄像机在正交投影模式下的视窗大小。该属性在 alignWithScreen 设置为 false 时生效。
camera.orthoSize = height / 2;
let texture = new cc.RenderTexture();
// 如果截图内容中不包含 Mask 组件,可以不用传递第三个参数
texture.initWithSize(width, height, cc.gfx.RB_FMT_S8);
// 如果设置了 targetTexture,那么摄像机渲染的内容不会输出到屏幕上,而是会渲染到 targetTexture 上。
camera.targetTexture = texture;
// 创建画布
let canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
let ctx = canvas.getContext('2d');
nodeCapture.setPosition(cc.Vec2.ZERO);
// 渲染一次摄像机,即更新一次内容到 RenderTexture 中
camera.render(nodeCapture);
nodeCapture.setPosition(position);
// 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。
// 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。
let data = texture.readPixels();
// write the render data
// PNG 中 1 像素 = 32 bit(RGBA),1 byte = 8 bit,所以 1 像素 = 4 byte
// 每行 width 像素,即 width * 4 字节
let rowBytes = width * 4;
for (let row = 0; row < height; row++) {
// RenderTexture 得到的纹理是上下翻转的
let srow = height - 1 - row;
let imageData = ctx.createImageData(width, 1);
let start = srow * width * 4;
for (let i = 0; i < rowBytes; i++) {
imageData.data[i] = data[start + i];
}
ctx.putImageData(imageData, 0, row);
}
let dataURL = canvas.toDataURL("image/png");
let img = document.createElement("img");
img.src = dataURL;
nodeCamera.destroy();
let texture2D = new cc.Texture2D();
texture2D.initWithElement(img);
let spriteFrame = new cc.SpriteFrame();
spriteFrame.setTexture(texture2D);
let node = new cc.Node();
let sprite = node.addComponent(cc.Sprite);
sprite.spriteFrame = spriteFrame;
nodeCapture.scaleX = 1;
return spriteFrame;
},
});
{
"ver": "1.0.8",
"uuid": "609efd2d-8c8b-4b9a-aa58-6186e15395a0",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export default class PageEffectAssemblerBase extends cc.Assembler {
// 普通四边形的属性,根据实际的顶点格式、数量调整
protected verticesCount = 4;
protected indicesCount = 6;
protected floatsPerVert = 5;
protected colorOffset = 4;
protected renderData: cc.RenderData = null;
get verticesFloats() {
return this.verticesCount * this.floatsPerVert;
}
getBuffer() {
//@ts-ignore
return cc.renderer._handle.getBuffer("mesh", this.getVfmt());
}
getVfmt() {
// to be overwrite
return null;
}
updateColor(comp, color) {
let uintVerts = this.renderData.uintVDatas[0];
if (!uintVerts) return;
color = color != null ? color : comp.node.color._val;
let floatsPerVert = this.floatsPerVert;
let colorOffset = this.colorOffset;
for (let i = colorOffset, l = uintVerts.length; i < l; i += floatsPerVert) {
uintVerts[i] = color;
}
}
updateIsFront(comp, dataOffset) {
let verts = this.renderData.vDatas[0];
let index = 0;
let floatsPerVert = this.floatsPerVert;
for (let i = 0, n = this.verticesCount; i < n; ++i) {
index = i * floatsPerVert;
let isFirstVert = i % 2 === 0;
let firstVertX = isFirstVert ? verts[index] : verts[index - floatsPerVert];
let secondVertX = isFirstVert ? verts[index + floatsPerVert] : verts[index];
let isFront = firstVertX < secondVertX ? 1.0 : 0.0;
verts[index + dataOffset] = isFront;
}
}
initData() {
//@ts-ignore
this.renderData = new cc.RenderData();
this.renderData.init(this);
let data = this.renderData;
// createFlexData支持创建指定格式的renderData
data.createFlexData(0, this.verticesCount, this.indicesCount, this.getVfmt());
// 顶点数固定的情况下索引不变化
let indices = data.iDatas[0];
let count = indices.length / 6;
for (let i = 0, idx = 0; i < count; i++) {
let vertextID = i * 4;
indices[idx++] = vertextID;
indices[idx++] = vertextID+1;
indices[idx++] = vertextID+2;
indices[idx++] = vertextID+1;
indices[idx++] = vertextID+3;
indices[idx++] = vertextID+2;
}
}
fillBuffers(comp, renderer) {
let renderData = this.renderData;
let vData = renderData.vDatas[0];
let iData = renderData.iDatas[0];
let buffer = this.getBuffer();
let offsetInfo = buffer.request(this.verticesCount, this.indicesCount);
let vertexOffset = offsetInfo.byteOffset >> 2,
vbuf = buffer._vData;
if (vData.length + vertexOffset > vbuf.length) {
vbuf.set(vData.subarray(0, vbuf.length - vertexOffset), vertexOffset);
} else {
vbuf.set(vData, vertexOffset);
}
let ibuf = buffer._iData,
indiceOffset = offsetInfo.indiceOffset,
vertexId = offsetInfo.vertexOffset;
for (let i = 0, l = iData.length; i < l; i++) {
ibuf[indiceOffset++] = vertexId + iData[i];
}
}
}
{
"ver": "1.0.8",
"uuid": "5314e480-f4d0-4b9d-a20c-7c7bc789fbab",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "34fd68c3-ee66-4456-9cb3-15b8cc3478b7",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export function getPosByAngle(angle, len) {
const radian = angle * Math.PI / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
return { x, y };
}
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor(180 / (Math.PI / radina) * 100) / 100; // 将弧度转换成角度
if (mx > px && my > py) {// 鼠标在第四象限
angle = 180 - angle;
}
if (mx === px && my > py) {// 鼠标在y轴负方向上
angle = 180;
}
if (mx > px && my === py) {// 鼠标在x轴正方向上
angle = 90;
}
if (mx < px && my > py) {// 鼠标在第三象限
angle = 180 + angle;
}
if (mx < px && my === py) {// 鼠标在x轴负方向
angle = 270;
}
if (mx < px && my < py) {// 鼠标在第二象限
angle = 360 - angle;
}
// console.log('angle: ', angle);
return angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
}
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
}
export function setSprNodeMaxLen(sprNode, maxW, maxH) {
const sx = maxW / sprNode.width;
const sy = maxH / sprNode.height;
const s = Math.min(sx, sy);
sprNode.scale = Math.round(s * 1000) / 1000;
}
export function localPosTolocalPos(baseNode, targetNode) {
const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function worldPosToLocalPos(worldPos, baseNode) {
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
const worldRect1 = targetNode.getBoundingBoxToWorld();
const worldRect2 = baseNode.getBoundingBoxToWorld();
const sx = worldRect1.width / worldRect2.width;
const sy = worldRect1.height / worldRect2.height;
if (maxFlag) {
return Math.max(sx, sy);
} else {
return Math.min(sx, sy);
}
}
export function getDistance (start, end){
var pos = cc.v2(start.x - end.x, start.y - end.y);
var dis = Math.sqrt(pos.x*pos.x + pos.y*pos.y);
return dis;
}
export function playAudioByUrl(audio_url, cb=null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
}
}
export function btnClickAnima(btn, time=0.15, rate=1.05) {
btn.tmpScale = btn.scale;
btn.on(cc.Node.EventType.TOUCH_START, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.scale * rate})
.start()
})
btn.on(cc.Node.EventType.TOUCH_CANCEL, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.start()
})
btn.on(cc.Node.EventType.TOUCH_END, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.start()
})
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "ade7af40-d56d-4087-bbc6-2888fef55353",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export function getPosByAngle(angle, len) {
const radian = angle * Math.PI / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
return { x, y };
}
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor(180 / (Math.PI / radina) * 100) / 100; // 将弧度转换成角度
if (mx > px && my > py) {// 鼠标在第四象限
angle = 180 - angle;
}
if (mx === px && my > py) {// 鼠标在y轴负方向上
angle = 180;
}
if (mx > px && my === py) {// 鼠标在x轴正方向上
angle = 90;
}
if (mx < px && my > py) {// 鼠标在第三象限
angle = 180 + angle;
}
if (mx < px && my === py) {// 鼠标在x轴负方向
angle = 270;
}
if (mx < px && my < py) {// 鼠标在第二象限
angle = 360 - angle;
}
// console.log('angle: ', angle);
return angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
}
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
export function Between(a, b, c) {
return [a, b, c].sort((a, b) => a - b)[1];
}
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
}
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
export async function asyncPlayDragonBoneAnimation(node, animationName, time = 1, onFrameEvent) {
return new Promise((resolve, reject) => {
node.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => {
resolve();
});
node.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof (onFrameEvent) == 'function') {
onFrameEvent(name);
}
});
node.getComponent(dragonBones.ArmatureDisplay)
.playAnimation(animationName, time);
});
}
export async function asyncPlayEffectByUrl(url, loop = false) {
return new Promise((resolve, reject) => {
cc.assetManager.loadRemote(url, (err, clip) => {
console.log(clip);
cc.audioEngine.playEffect(clip, loop);
resolve();
});
});
}
export async function jelly(node) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(0.1, { scaleX: 0.9, scaleY: 1.1 })
.to(0.1, { scaleX: 1.1, scaleY: 0.9 })
.to(0.1, { scaleX: 1, scaleY: 1 })
.call(resolve)
.start();
});
}
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, time * 1000);
})
}
export async function showFireworks(baseNode, nodeList, pos = cc.v2(0, 0), side = cc.v2(0, 100), range = 50, number = 100) {
new Array(number).fill(' ').forEach(async (_, i) => {
let rabbonNode = new cc.Node();
rabbonNode.parent = baseNode;
rabbonNode.x = pos.x;
rabbonNode.y = pos.y;
rabbonNode.angle = 60 * Math.random() - 30;
let node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
node.parent = rabbonNode;
node.active = true;
node.x = 0;
node.y = 0;
node.angle = 0;
const rate = Math.random();
const angle = Math.PI * (Math.random() * 2 - 1);
await asyncTweenBy(rabbonNode, 0.3, {
x: side.x * rate + Math.cos(angle) * range * rate,
y: side.y * rate + Math.sin(angle) * range * rate
}, {
easing: 'quadIn'
});
cc.tween(rabbonNode)
.by(8, { y: -2000 })
.start();
rabbonFall(rabbonNode);
await asyncDelay(Math.random());
cc.tween(node)
.by(0.15, { x: -10, angle: -10 })
.by(0.3, { x: 20, angle: 20 })
.by(0.15, { x: -10, angle: -10 })
.union()
.repeatForever()
.start();
cc.tween(rabbonNode)
.delay(5)
.to(0.3, { opacity: 0 })
.call(() => {
node.stopAllActions();
node.active = false;
node.parent = null;
node = null;
})
.start();
});
}
async function rabbonFall(node) {
const time = 1 + Math.random();
const offsetX = RandomInt(-200, 200) * time;
await asyncTweenBy(node, time, { x: offsetX, angle: offsetX * 60 / 200 });
rabbonFall(node);
}
export function loadSpine(skeleton, picName, {tex, atlas, ske}) {
return new Promise((resolve, reject) => {
// cc.loader.load({ url: tex, type: 'png' }, (error, texture) => {
cc.assetManager.loadRemote(tex, (error, texture) => {
if (error) {
reject();
return;
}
// cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.assetManager.loadAny({ url: atlas }, (error, atlasJson) => {
if (error) {
reject();
return;
}
// cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
cc.assetManager.loadAny({ url: ske }, (error, dragonBonesJson) => {
if (error) {
reject();
return;
}
var asset = new sp.SkeletonData();
asset._uuid = ske;
asset.skeletonJson = JSON.stringify( dragonBonesJson );
asset.atlasText = atlasJson;
asset.textures = [texture];
asset.textureNames = [picName];
console.log('picName: ', picName);
skeleton.skeletonData = asset;
const jsonObj = dragonBonesJson //JSON.parse( assets[1]);
const animationNameObj = jsonObj.animations;
let animationNames = [];
for (let name in animationNameObj) {
console.log('name~~: ', name);
animationNames.push(name);
}
console.log("skeleton.animation: ", skeleton.animation);
skeleton.animationNames = animationNames;
skeleton.loop = false;
console.log("jsonObj : ", jsonObj)
console.log("jsonObj['skeleton'] : ", jsonObj['skeleton'])
resolve(jsonObj['skeleton']);
});
});
});
});
}
export function onHomeworkFinish() {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
}
} else {
console.log('onHomeworkFinish');
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "d545f402-231b-417e-99e6-3269412a5a2c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import PageEffectAssemblerBase from "./page_effect_assembler_base";
const gfx = cc.gfx
let vfmtPosUvColorFront = new gfx.VertexFormat([
{ name: gfx.ATTR_POSITION, type: gfx.ATTR_TYPE_FLOAT32, num: 2 },
{ name: gfx.ATTR_UV0, type: gfx.ATTR_TYPE_FLOAT32, num: 2 },
{ name: gfx.ATTR_COLOR, type: gfx.ATTR_TYPE_UINT8, num: 4, normalize: true },
{ name: "a_isFront", type: gfx.ATTR_TYPE_FLOAT32, num: 1},
]);
export default class VerletAssembler extends PageEffectAssemblerBase {
init(comp: cc.RenderComponent) {
super.init(comp);
//@ts-ignore
let segmentCount = comp.pointsCount - 1;
this.verticesCount = 4 * segmentCount;
this.indicesCount = 6 * segmentCount;
this.floatsPerVert = 6;
this.initData();
}
getVfmt() {
return vfmtPosUvColorFront;
}
public updateRenderData (comp: any) {
if (comp) {
let pointList: cc.Vec2[] = comp.getPointList()
let pointNum: number = pointList.length
if (pointNum < 2) {
return
}
let node = comp.node
let height = node.height
let width = node.width
let posX = - width * node.anchorX
let posY = - height * node.anchorY
let gapU = 1 / (pointNum - 1)
let lastU = 0
let nextU = 0
let floatsPerVert = this.floatsPerVert;
let verts = this.renderData.vDatas[0];
// 写verts时的下标
let dstOffset = 0;
for (let i = 1; i < pointNum; i++) {
let lastPoint = pointList[i - 1]
let nextPoint = pointList[i]
nextU = lastU + gapU
// 顶点和质点一一对应
// 顶点数据写入verts
dstOffset = floatsPerVert * (i-1) * 4;
verts[dstOffset] = posX + lastPoint.x;
verts[dstOffset + 1] = posY + lastPoint.y;
verts[dstOffset + 2] = lastU;
verts[dstOffset + 3] = 1;
dstOffset += floatsPerVert;
verts[dstOffset] = posX + nextPoint.x;
verts[dstOffset + 1] = posY + nextPoint.y;
verts[dstOffset + 2] = nextU;
verts[dstOffset + 3] = 1;
dstOffset += floatsPerVert;
verts[dstOffset] = posX + lastPoint.x;
verts[dstOffset + 1] = posY + height + lastPoint.y;
verts[dstOffset + 2] = lastU;
verts[dstOffset + 3] = 0;
dstOffset += floatsPerVert;
verts[dstOffset] = posX + nextPoint.x;
verts[dstOffset + 1] = posY + height + nextPoint.y;
verts[dstOffset + 2] = nextU;
verts[dstOffset + 3] = 0;
lastU = nextU
}
this.updateColor(comp, null);
this.updateIsFront(comp, 5);
}
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "9694fac7-c6ac-426b-b854-93c0ba8913b3",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import VerletAssembler from "./verlet_assembler";
const { ccclass, property } = cc._decorator;
class PagePoint {
public oldPos: cc.Vec2
public newPos: cc.Vec2
constructor(x: number, y: number) {
this.oldPos = this.newPos = cc.v2(x, y)
}
}
@ccclass
export default class VerletRender extends cc.RenderComponent {
@property({ type: [cc.Texture2D], displayName: "纹理" })
public textureList: cc.Texture2D[] = []
@property({ displayName: "每条边上的顶点数量" })
public pointsCount: number = 30
@property({ displayName: "纠正次数" })
public constraintTimes: number = 100
@property({ displayName: "速度衰减系数" })
public damping: number = 0.1
@property({ displayName: "重力" })
public gravity: number = 0
protected _initedMaterial: boolean = false
private _pointList: PagePoint[] = []
private _angle: number = 0
onEnable() {
super.onEnable();
this.initPointList();
this.draw();
}
public _resetAssembler() {
let assembler = this._assembler = new VerletAssembler()
assembler.init(this)
}
protected _updateMaterial() {
let material = this.getMaterial(0)
if (material) {
material.define('CC_USE_MODEL', 1);
if (this.textureList.length === 2) {
material.setProperty('texture0', this.textureList[0]);
material.setProperty('texture1', this.textureList[1]);
}
}
}
protected updateMaterial() {
if (this.textureList.length === 2) {
this._updateMaterial()
this._initedMaterial = true
return
}
}
public updateAngle(angle: number) {
this._angle = angle
}
public getPointList() {
let pointList: cc.Vec2[] = []
for (let point of this._pointList) {
pointList.push(new cc.Vec2(point.newPos.x, point.newPos.y))
}
return pointList
}
// 初始化质点
public initPointList() {
for (let i = 0; i < this.pointsCount; ++i) {
let posX = i / (this.pointsCount - 1) * this.node.width
this._pointList.push(new PagePoint(posX, 0))
}
}
public update() {
this.simulate()
this.applyConstraint()
this.draw()
}
// 使用verlet积分更新位置
public simulate() {
let gravity = cc.v2(0, this.gravity)
for (let i = this.pointsCount - 1; i >= 1; i--) {
let point = this._pointList[i]
// 速度等于当前位置与上一个位置的差乘上衰减系数
let velocity: cc.Vec2 = point.newPos.sub(point.oldPos).mul(this.damping)
// 模拟一个水平放置的绳子,当y小于等于0时,将不再受重力影响
if (point.newPos.y <= 0) {
gravity.y = Math.max(0, gravity.y)
}
point.oldPos = point.newPos
point.newPos = point.newPos.add(velocity)
point.newPos = point.newPos.add(gravity)
}
}
private _updateEndPos(endPos: cc.Vec2) {
let tailPoint = this._pointList[this.pointsCount - 1]
tailPoint.newPos = new cc.Vec2(endPos.x, endPos.y)
}
private _getEndPos(): cc.Vec2 {
let endPos = new cc.Vec2(0, 0)
let width = this.node.width
let rad = this._angle * Math.PI / 180
// 与贝塞尔曲线使用相同的运动轨迹
let per = rad * 2 / Math.PI
if (this._angle <= 90) {
let endPosX = width * (1 - Math.pow(per, 3))
let endPosY = width * 1 / 4 * (1 - Math.pow(1 - per, 4))
endPos = new cc.Vec2(endPosX, endPosY)
} else {
per = per - 1
let endPosX = - width * (1 - Math.pow(1 - per, 3))
let endPosY = width * 1 / 4 * (1 - Math.pow(per, 4))
endPos = new cc.Vec2(endPosX, endPosY)
}
return endPos
}
// 约束纠正
public applyConstraint() {
// 两个质点之间的固定距离
let normalDistance = this.node.width / (this.pointsCount - 1)
let endPos = this._getEndPos()
for (let t = 0; t < this.constraintTimes; t++) {
this._updateEndPos(endPos)
//由最后一个质点开始依次纠正
for (let i = this.pointsCount - 1; i >= 1; i--) {
let firstPoint = this._pointList[i - 1]
let secondPoint = this._pointList[i]
let delatPos = secondPoint.newPos.sub(firstPoint.newPos)
let distance = delatPos.mag()
let fixDirection: cc.Vec2 = null
if (distance < normalDistance) {
fixDirection = delatPos.normalize().negate()
} else if (distance > normalDistance) {
fixDirection = delatPos.normalize()
} else {
continue
}
let fixLen = Math.abs(distance - normalDistance)
if (i == 1) {
// 由于第一个质点是固定的,所以只对第二个质点做纠正
let fixVector = fixDirection.mul(fixLen)
secondPoint.newPos.subSelf(fixVector)
} else {
// 将两个质点之间的距离纠正为固定长度
let fixHalfVector = fixDirection.mul(fixLen * 0.5)
firstPoint.newPos.addSelf(fixHalfVector)
secondPoint.newPos.subSelf(fixHalfVector)
}
}
}
}
public draw() {
if (!this._initedMaterial) {
this.updateMaterial()
}
this.setVertsDirty()
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "5b959940-b8bc-4a57-8e86-6e135d3bb8d8",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "5ec153c1-caa5-422d-8520-0a0de4105de9",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture0: { value: white }
texture1: { value: white }
alphaThreshold: { value: 0.5 }
}%
CCProgram vs %{
precision highp float;
#include <cc-global>
#include <cc-local>
in vec3 a_position;
in vec4 a_color;
out vec4 v_color;
#if USE_TEXTURE
in vec2 a_uv0;
out vec2 v_uv0;
in float a_isFront;
out float v_isFront;
#endif
void main () {
vec4 pos = vec4(a_position, 1);
#if CC_USE_MODEL
pos = cc_matViewProj * cc_matWorld * pos;
#else
pos = cc_matViewProj * pos;
#endif
#if USE_TEXTURE
v_uv0 = a_uv0;
#endif
v_color = a_color;
v_isFront = a_isFront;
gl_Position = pos;
}
}%
CCProgram fs %{
precision highp float;
#include <alpha-test>
in vec4 v_color;
#if USE_TEXTURE
in vec2 v_uv0;
in float v_isFront;
uniform sampler2D texture0;
uniform sampler2D texture1;
#endif
void main () {
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
if(v_isFront == 1.0) {
o *= texture(texture0, v_uv0);
} else {
o *= texture(texture1, v_uv0);
}
#if CC_USE_ALPHA_ATLAS_TEXTURE
o.a *= texture2D(texture, v_uv0).r;
#endif
#endif
o *= v_color;
ALPHA_TEST(o);
gl_FragColor = o;
}
}%
{
"ver": "1.0.25",
"uuid": "71f0ba7f-9abb-4754-9100-100e47c782bc",
"compiledShaders": [
{
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\nattribute float a_isFront;\nvarying float v_isFront;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n v_isFront = a_isFront;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nvarying float v_isFront;\nuniform sampler2D texture0;\nuniform sampler2D texture1;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n if(v_isFront == 1.0) {\n o *= texture2D(texture0, v_uv0);\n } else {\n o *= texture2D(texture1, v_uv0);\n }\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
},
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\nin float a_isFront;\nout float v_isFront;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n v_isFront = a_isFront;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nin float v_isFront;\nuniform sampler2D texture0;\nuniform sampler2D texture1;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n if(v_isFront == 1.0) {\n o *= texture(texture0, v_uv0);\n } else {\n o *= texture(texture1, v_uv0);\n }\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
}
}
],
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.Material",
"_name": "page-material",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "71f0ba7f-9abb-4754-9100-100e47c782bc"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {
"USE_TEXTURE": true
}
}
}
}
\ No newline at end of file
{
"ver": "1.0.3",
"uuid": "4f7c0520-945f-4c7c-9b51-9c012fca0299",
"dataAsSubAsset": null,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "8ba21262-178f-4fa5-afc9-2c1dd50ba3ab",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "5d3dbf71-3907-492a-8140-e402460ca901",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "ce0a0ad1-ea3c-4943-b4df-0018e6fdc873",
"subMetas": {}
}
\ No newline at end of file
{"name":"mao","imagePath":"mao_tex.png","SubTexture":[{"name":"猫01/影子","x":1,"height":66,"y":343,"width":337},{"name":"猫01/尾巴","x":1,"height":109,"y":188,"width":175},{"name":"猫01/右腿","x":178,"height":117,"y":188,"width":104},{"name":"猫01/左腿","x":1,"height":115,"y":569,"width":64},{"name":"猫01/右手","x":427,"height":122,"y":590,"width":69},{"name":"猫01/左手","x":301,"height":74,"y":590,"width":124},{"name":"猫01伸/左手伸直","x":299,"height":169,"y":1,"width":168},{"name":"猫01伸/右手伸直","x":299,"height":169,"y":172,"width":168},{"name":"猫01/身体","x":340,"height":180,"y":343,"width":122},{"name":"猫01/领带","x":1,"height":156,"y":411,"width":120},{"name":"猫01/右耳","x":155,"height":76,"y":602,"width":90},{"name":"猫01/左耳","x":67,"height":85,"y":602,"width":86},{"name":"猫01/组_1","x":1,"height":185,"y":1,"width":296},{"name":"猫01/右眼","x":1,"height":60,"y":686,"width":59},{"name":"猫01/右眉毛","x":67,"height":5,"y":595,"width":33},{"name":"猫01/左眼","x":247,"height":60,"y":666,"width":59},{"name":"猫01/左眉毛","x":247,"height":12,"y":602,"width":31},{"name":"猫01/眼镜","x":301,"height":63,"y":525,"width":170},{"name":"猫01/胡子","x":123,"height":85,"y":515,"width":176},{"name":"猫01/鼻子","x":67,"height":24,"y":569,"width":28},{"name":"猫01/嘴","x":1,"height":30,"y":299,"width":65},{"name":"猫01/帽子","x":123,"height":102,"y":411,"width":158}],"height":1024,"width":512}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "0beeaa34-33fe-41c8-9ced-36f73b9f71a7",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "4dfebff1-7d99-40fb-8f61-c515e6ff3e9e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 1024,
"platformSettings": {},
"subMetas": {
"mao_tex": {
"ver": "1.0.4",
"uuid": "795b7b2c-7018-4e77-bdad-bfb8099e01df",
"rawTextureUuid": "4dfebff1-7d99-40fb-8f61-c515e6ff3e9e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7.5,
"offsetY": 138.5,
"trimX": 1,
"trimY": 1,
"width": 495,
"height": 745,
"rawWidth": 512,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "8540e37b-f678-4ca6-93df-acc60a7b2b9d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f8289e25-f396-4d4f-b746-1d1e8d3a3934",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 502,
"height": 115,
"platformSettings": {},
"subMetas": {
"574": {
"ver": "1.0.4",
"uuid": "b116b474-3816-410e-ab8b-7cc1f1d833e9",
"rawTextureUuid": "f8289e25-f396-4d4f-b746-1d1e8d3a3934",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 502,
"height": 115,
"rawWidth": 502,
"rawHeight": 115,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"__type__": "cc.SpriteAtlas"
}
\ No newline at end of file
{
"ver": "1.2.1",
"uuid": "08a510bb-5f41-4f70-8c5e-710c0cfeefc5",
"maxWidth": 2048,
"maxHeight": 2048,
"padding": 2,
"allowRotation": true,
"forceSquared": false,
"powerOfTwo": false,
"algorithm": "MaxRects",
"format": "png",
"quality": 80,
"contourBleed": true,
"paddingBleed": true,
"filterUnused": true,
"packable": false,
"premultiplyAlpha": false,
"filterMode": "bilinear",
"platformSettings": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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