Commit 509ead2c authored by 李维's avatar 李维

还原工程

parent 3ab5b6aa
No preview for this file type
{
"ver": "1.1.2",
"uuid": "2d7fba1a-8174-4ebb-b28c-d6fed89e48e3",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"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": "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": "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": "debd6cea-1475-4d46-a5c5-02b2540f97f4",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b",
"downloadMode": 0,
"duration": 10.944,
"duration": 0.130612,
"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": "36abc766-60c3-40c3-965f-8232c750d9db",
"uuid": "0853721c-3f55-4eb2-873d-e3081cfadd4b",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.0",
"uuid": "45471cc5-3d53-4068-99c4-591121300416",
"uuid": "c551970e-b095-45f3-9f1d-25cde8b8deb1",
"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.2.9",
"uuid": "57ea7c61-9b8b-498a-b024-c98ee9124beb",
"uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
......
const saveKey = "DataKey_Cocos_FT14";
const BaseUI = require('BaseUI');
import { DefaultData } from '../script/DefaultData';
import { jelly, onHomeworkFinish } from "../script/utils";
import EventMgr from '../script/EventMgr'
cc.Class({
extends: BaseUI,
properties: {
},
// 生命周期 onLoad
onLoad() {
},
// 生命周期 start
start() {
const pic = cc.find('Canvas/page/mask/bezier/page');
const picURL = 'http://staging-teach.cdn.ireadabc.com/98c63573-1d3a-4997-bfb8-71bb111ce2ec.png';
this.loadNetImg(picURL).then((texture) => {
pic.getComponent('bezier-render').textureList[0] = texture
pic.getComponent('bezier-render').init();
})
this.loadNetImg(picURL).then((texture) => {
pic.getComponent('bezier-render').textureList[0] = texture
pic.getComponent('bezier-render').init();
})
setTimeout(() => {
EventMgr.emit('page_to_left')
}, 1000);
},
loadNetImg: function (url) {
return new Promise((resolve, reject) => {
cc.loader.load({ url }, (err, texture) => {
if (err && !texture) return resolve(pg.logger.w('loading loadRes warn-> ' + texture));
resolve(texture);
});
})
},
});
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
}
onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
_cantouch = null;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
}
initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
}
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
// update (dt) {},
initListener() {
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
{
"ver": "1.0.8",
"uuid": "f4ede462-f8d7-4069-ba80-915611c058ca",
"uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
cc.Class({
extends: cc.Component,
onLoad() {
console.log("Ls");
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
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
/**
* 事件模块
* 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() {
console.log("L");
// 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('');
})
}
});
},
stopSpine() {
if (this._aniSpine) {
const skeleton = this.skeleton;
skeleton.clearTracks();
}
if (this._aniDragonBone) {
this._aniDragonBone.stop();
}
},
playSpine() {
return new Promise((resolve, reject) => {
if (this.data.pageDragonBone.animType == 'spine') {
const skeleton = this.skeleton;
skeleton.setToSetupPose();
setTimeout(() => {
this._aniSpine = skeleton.setAnimation(0, this.animationName, false);
skeleton.setCompleteListener(() => {
this._aniSpine = null;
GameData.isPlaying = 0;
resolve('');
})
}, 1);
} else {
this._aniDragonBone = this.dragonBone.playAnimation(this.animationName, 1);
this.dragonBone.on(dragonBones.EventObject.COMPLETE, (evt) => {
this._aniDragonBone = null;
GameData.isPlaying = 0;
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 = 0;
},
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
import { defaultData } from "../script/defaultData";
export class MyCocosSceneComponent extends cc.Component {
// 生命周期 onLoad
onLoad() {
this.initSceneData();
this.initSize();
}
_imageResList = null;
_audioResList = null;
_animaResList = null;
initSceneData() {
this._imageResList = [];
this._audioResList = [];
this._animaResList = [];
}
_designSize = null; // 设计分辨率
_frameSize = null; // 屏幕分辨率
_mapScaleMin = null; // 场景中常用缩放(取大值)
_mapScaleMax = null; // 场景中常用缩放(取小值)
_cocosScale = null; // cocos 自缩放 (较少用到)
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
this._designSize = cc.view.getDesignResolutionSize();
let sx = cc.winSize.width / frameSize.width;
let sy = cc.winSize.height / frameSize.height;
this._cocosScale = Math.min(sx, sy);
sx = frameSize.width / this._designSize.width;
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
cc.director['_scene'].width = frameSize.width;
cc.director['_scene'].height = frameSize.height;
}
data = null;
// 生命周期 start
start() {
if (window && (<any>window).courseware && (<any>window).courseware.getData) {
(<any>window).courseware.getData((data) => {
this.log('data:' + data);
this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data));
this.preloadItem();
})
} else {
this.data = this.getDefaultData();
this.preloadItem();
}
}
getDefaultData() {
return defaultData;
}
preloadItem() {
this.addPreloadImage();
this.addPreloadAudio();
this.addPreloadAnima();
this.preload();
}
addPreloadImage() {
}
addPreloadAudio() {
}
addPreloadAnima() {
}
preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
if (window && window["air"]) {
// window["air"].onCourseInScreen = (next) => {
// window["air"].isCourseInScreen = true;
// this.onLoadEnd();
// next();
// };
this.onLoadEnd();
window["air"].hideAirClassLoading();
} else {
this.onLoadEnd();
}
cc.debug.setDisplayStats(false);
});
}
log (str) {
const node = cc.find('middleLayer');
if(node){
node.getComponent('middleLayer').log(str);
}else{
cc.log(str);
}
}
onLoadEnd() {
}
// ------------------------------------------------
getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
node.addComponent(cc.Sprite).spriteFrame = sf;
return node;
}
getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
}
getSprNodeByUrl(url, cb) {
const node = new cc.Node();
const spr = node.addComponent(cc.Sprite);
this.getSpriteFrimeByUrl(url, (sf) => {
spr.spriteFrame = sf;
if (cb) {
cb(node);
}
})
}
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();
});
}
});
}else{
cb && cb();
}
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "7af27a40-c9d2-4101-b894-8dff982f3985",
"uuid": "f8b451ff-857c-4ca8-9870-866bc5154a29",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
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 () {
console.log("L收到VS的VS的");
// 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 const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "6fa9c94a-d3df-4f14-bf6b-b6aa701eb398",
"uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
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
......@@ -5,7 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/
!(function(global) {
cc.sys.capabilities["touches"] = true;
!(function (global) {
"use strict";
var Op = Object.prototype;
......@@ -78,9 +80,9 @@
// .constructor.prototype properties for functions that return Generator
// objects. For full spec compliance, you may wish to configure your
// minifier not to mangle the names of these two functions.
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
function Generator() { }
function GeneratorFunction() { }
function GeneratorFunctionPrototype() { }
// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
......@@ -92,8 +94,8 @@
var getProto = Object.getPrototypeOf;
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
......@@ -109,24 +111,24 @@
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function(method) {
prototype[method] = function(arg) {
["next", "throw", "return"].forEach(function (method) {
prototype[method] = function (arg) {
return this._invoke(method, arg);
};
});
}
runtime.isGeneratorFunction = function(genFun) {
runtime.isGeneratorFunction = function (genFun) {
var ctor = typeof genFun === "function" && genFun.constructor;
return ctor
? ctor === GeneratorFunction ||
// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
(ctor.displayName || ctor.name) === "GeneratorFunction"
// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
(ctor.displayName || ctor.name) === "GeneratorFunction"
: false;
};
runtime.mark = function(genFun) {
runtime.mark = function (genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
} else {
......@@ -143,7 +145,7 @@
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
runtime.awrap = function(arg) {
runtime.awrap = function (arg) {
return { __await: arg };
};
......@@ -156,16 +158,16 @@
var result = record.arg;
var value = result.value;
if (value &&
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return Promise.resolve(value.__await).then(function(value) {
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return Promise.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function(err) {
}, function (err) {
invoke("throw", err, resolve, reject);
});
}
return Promise.resolve(value).then(function(unwrapped) {
return Promise.resolve(value).then(function (unwrapped) {
// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration. If the Promise is rejected, however, the
......@@ -191,7 +193,7 @@
function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
......@@ -231,16 +233,16 @@
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
runtime.async = function(innerFn, outerFn, self, tryLocsList) {
runtime.async = function (innerFn, outerFn, self, tryLocsList) {
var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList)
);
return runtime.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
: iter.next().then(function(result) {
return result.done ? result.value : iter.next();
});
: iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
};
function makeInvokeMethod(innerFn, self, context) {
......@@ -366,7 +368,7 @@
var info = record.arg;
if (! info) {
if (!info) {
context.method = "throw";
context.arg = new TypeError("iterator result is not an object");
context.delegate = null;
......@@ -414,11 +416,11 @@
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
Gp[iteratorSymbol] = function() {
Gp[iteratorSymbol] = function () {
return this;
};
Gp.toString = function() {
Gp.toString = function () {
return "[object Generator]";
};
......@@ -453,7 +455,7 @@
this.reset(true);
}
runtime.keys = function(object) {
runtime.keys = function (object) {
var keys = [];
for (var key in object) {
keys.push(key);
......@@ -523,7 +525,7 @@
Context.prototype = {
constructor: Context,
reset: function(skipTempReset) {
reset: function (skipTempReset) {
this.prev = 0;
this.next = 0;
// Resetting context._sent for legacy support of Babel's
......@@ -541,15 +543,15 @@
for (var name in this) {
// Not sure about the optimal order of these conditions:
if (name.charAt(0) === "t" &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},
stop: function() {
stop: function () {
this.done = true;
var rootEntry = this.tryEntries[0];
......@@ -561,7 +563,7 @@
return this.rval;
},
dispatchException: function(exception) {
dispatchException: function (exception) {
if (this.done) {
throw exception;
}
......@@ -579,7 +581,7 @@
context.arg = undefined;
}
return !! caught;
return !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
......@@ -621,22 +623,22 @@
}
},
abrupt: function(type, arg) {
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev &&
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc) {
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
if (finallyEntry &&
(type === "break" ||
type === "continue") &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc) {
(type === "break" ||
type === "continue") &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc) {
// Ignore the finally entry if control is not jumping to a
// location outside the try/catch block.
finallyEntry = null;
......@@ -655,13 +657,13 @@
return this.complete(record);
},
complete: function(record, afterLoc) {
complete: function (record, afterLoc) {
if (record.type === "throw") {
throw record.arg;
}
if (record.type === "break" ||
record.type === "continue") {
record.type === "continue") {
this.next = record.arg;
} else if (record.type === "return") {
this.rval = this.arg = record.arg;
......@@ -674,7 +676,7 @@
return ContinueSentinel;
},
finish: function(finallyLoc) {
finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) {
......@@ -685,7 +687,7 @@
}
},
"catch": function(tryLoc) {
"catch": function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
......@@ -703,7 +705,7 @@
throw new Error("illegal catch attempt");
},
delegateYield: function(iterable, resultName, nextLoc) {
delegateYield: function (iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
......@@ -723,5 +725,5 @@
// In sloppy mode, unbound `this` refers to the global object, fallback to
// Function constructor if we're in global strict mode. That is sadly a form
// of indirect eval which violates Content Security Policy.
(function() { return this })() || Function("return this")()
(function () { return this })() || Function("return this")()
);
{
"ver": "1.0.8",
"uuid": "34fd68c3-ee66-4456-9cb3-15b8cc3478b7",
"isPlugin": false,
"uuid": "b54300af-b8e5-4b4e-aa2f-9ac1cef7b598",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
......
export default printInfo = () => {
console.log("Test-001");
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "264b9128-c542-4d60-b7d7-0c64e87ecd75",
"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
This diff is collapsed.
This diff is collapsed.
{
"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
This diff is collapsed.
{
"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
This diff is collapsed.
{
"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
This diff is collapsed.
{
"ver": "1.0.3",
"uuid": "4f7c0520-945f-4c7c-9b51-9c012fca0299",
"dataAsSubAsset": null,
"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.
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