后裔逐日简化版

This commit is contained in:
YZ\249929363 2024-10-30 15:26:27 +08:00
commit c246b4b728
755 changed files with 239471 additions and 0 deletions

13
assets/Scene.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

9033
assets/Scene/GameScene.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "4eaf518b-35ec-4262-928d-4d497c3f2830",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}

5745
assets/Scene/GuideScene.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "774829bb-123e-48b6-930e-6b3e02491506",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}

11882
assets/Scene/LoadScene.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "9c08062d-4cf1-4b6e-a8ba-4a3881cc7e7d",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}

5838
assets/Scene/OverScene.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "4b9c5a7e-c645-48a4-9aca-5df381ce4ef5",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}

5505
assets/Scene/RankScene.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}

13
assets/Script.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,10 @@
cc.Class({
extends: cc.Component,
properties: {
},
onLoad () {
cc.dynamicAtlasManager.enabled = false;
},
});

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "5c9b8159-89a3-4b32-b303-b3d4f7ac1c9f",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,924 @@
// 主游戏控制类
const {ccclass, property} = cc._decorator;
@ccclass
export default class GameManager extends cc.Component {
@property(cc.Node)
ball: cc.Node = null;
@property(cc.Prefab)
qiu1: cc.Prefab = null;
@property(cc.Prefab)
qiu2: cc.Prefab = null;
@property(cc.Prefab)
qiu3: cc.Prefab = null;
@property(cc.Prefab)
linePrefab: cc.Prefab = null;
@property(cc.Node)
hit: cc.Node = null;
bg1: cc.Node = null;
bg2: cc.Node = null;
time: cc.Label = null;
begin: boolean = false;
fuhuo: boolean = false;
over: boolean = false;
show: boolean = false;
countTime:number;
timeCount:number;
fitTop:number;
fitBot:number;
level:number;
clickNow:number;
startTime:number;
overTime:number;
winTime:number;
clickCount:number;
timeStart:number;
route_Array: any[];
now_Array: any[];
ball_Array: any[];
Line_Array: any[];
Pos_Array: any[];
time_Array: any[];
color_Array: any[];
@property(cc.Label)
levelLabel: cc.Label = null;
static _instance: any;
moveArray: number[];
repeat: number;
numberRepeat: number;
round: number;
pause: boolean;
onLoad () {}
start () {
this.fit();
this.init();
}
//初始化数据
init(){
this.node.getChildByName("GameOver").zIndex = 100;
this.node.getChildByName("GameOver").active = false;
this.ball.zIndex = 100;
this.bg1 = this.node.getChildByName("bg1");
this.bg2 = this.node.getChildByName("bg2");
this.time = this.node.getChildByName("Top").getChildByName("time").getComponent(cc.Label);
this.node.getChildByName("showBtn").active = false;
this.begin = false;
this.over = false;
this.fuhuo = true;
this.pause = true;
this.show = false;
this.round = 0;
this.level = 2;
this.countTime = 60;
if(cc.fx.GameConfig.GM_INFO.custom != 0){
this.level = cc.fx.GameConfig.GM_INFO.custom;
// this.levelLabel.string = this.level + "";
cc.fx.GameConfig.GM_INFO.custom += 1;
this.countTime = 12000000;
}
// this.levelLabel.string = this.level + "";
this.timeCount = 0.1;
this.clickNow = 0;
this.clickCount = 0;
this.timeStart = 0;
this.repeat = -1;
this.numberRepeat = -1;
this.route_Array = [];
this.moveArray = [];
this.now_Array = [];
this.ball_Array = [];
this.Pos_Array = [];
this.time_Array = [];
this.color_Array = [];
cc.fx.GameConfig.GAME_DATA = [];
cc.fx.GameConfig.GM_INFO.success = false;
this.startTime = 0;
this.overTime = 0;
this.winTime = 0;
cc.fx.GameConfig.GM_INFO.total = 0;
cc.fx.GameConfig.GM_INFO.mean_Time = 0;
this.schedule(this.updateCountDownTime,1);
this.startGame();
}
//根据是否全面屏,做独立适配方面
fit(){
this.fitTop = 450; //600
this.fitBot = -600; //-700
var jg = this.setFit();
if(!jg){
this.fitTop = 600;
this.fitBot = -700;
}
}
//判断全面屏
getSetScreenResolutionFlag () {
let size = cc.winSize;
let width = size.width;
let height = size.height;
if ((height / width) > (16.2 / 9)) return false;
return true;
}
//判断全面屏适配
setFit () {
let flag = this.getSetScreenResolutionFlag();
if (flag) {
} else {
}
return flag;
}
//返回首页
backScene(){
cc.director.loadScene("LoadScene");
}
//下一关或者重新开始或者返回上一关根据level决定
reStart(type){
// if(cc.fx.GameConfig.GM_INFO.custom != 0){
// cc.director.loadScene("LoadScene");
// return;
// }
this.node.getChildByName("showBtn").active = false;
this.destroyLine();
this.timeCount = 0.1;
this.clickNow = 0;
this.timeStart = 0;
this.repeat = -1;
this.numberRepeat = -1;
this.begin = false;
this.route_Array = [];
this.now_Array = [];
this.ball_Array = [];
this.Pos_Array = [];
this.moveArray = [];
this.time_Array = [];
this.color_Array = [];
if(type == 0){
this.bgMove(1);
}
else if(type == 1){
this.startGame();
}
else if(type == 2){
this.bgMove(-1);
}
}
//获取时间戳
getTime(){
const timestamp = new Date().getTime();
return timestamp;
}
//获胜
passLevel(){
this.destroyLine();
if(this.over == false && this.countTime >= 0){
let timeArray = [];
let timeCount = 0;
let ball = this.ball_Array[0];
for(let i=1; i< this.ball_Array.length; i++){
let time = this.calculateDistance(this.ball_Array[i].x,this.ball_Array[i].y,
this.ball_Array[i-1].x,this.ball_Array[i-1].y,2);
timeArray.push(time);
}
for(let k=1; k< this.ball_Array.length; k++){
setTimeout(() => {
cc.tween(ball)
.to(timeArray[k-1],{x:this.ball_Array[k].x,y:this.ball_Array[k].y})
.call(() =>{
this.ball_Array[k].active = false;
if(k == this.ball_Array.length-1){
setTimeout(() => {
this.ball.opacity = 255;
this.ball.position = cc.v3(ball.x,ball.y,0);
ball.active = false;
this.clearSun();
this.reStart(0);
}, 200);
}
})
.start();
}, timeCount*1000);
timeCount += (timeArray[k-1]+0.1);
}
}
}
//失败
loseLevel(type){
this.destroyLine();
if(this.over == false && this.countTime >= 0){
let ball = this.ball_Array[0];
for(let k=1; k< this.ball_Array.length; k++){
cc.tween(this.ball_Array[k])
.to(2,{x:ball.x,y:ball.y})
.call(() =>{
this.ball_Array[k].active = false;
if(k == this.ball_Array.length-1){
this.ball.opacity = 255;
this.ball.position = cc.v3(ball.x,ball.y,0);
this.clearSun();
this.reStart(type);
}
})
.start()
}
}
}
//清理太阳
clearSun(){
for(let k=0; k< this.ball_Array.length; k++){
this.ball_Array[k].removeFromParent();
this.ball_Array[k] = null;
}
}
//点击太阳执行方法
clickSun(data){
if(this.begin == true){
this.clickCount += 1;
let clickTime = cc.fx.GameTool.getTime();
this.time_Array.push((clickTime - this.timeStart))
this.timeStart = cc.fx.GameTool.getTime();
if(data == this.clickNow){
cc.fx.AudioManager._instance.playAudioButton();
if(this.clickNow > 0){
this.createLine(cc.v2(this.ball_Array[this.clickNow-1].x,this.ball_Array[this.clickNow-1].y),
cc.v2(this.ball_Array[this.clickNow].x,this.ball_Array[this.clickNow].y),
0.2);
}
this.clickNow += 1;
if(this.ball_Array[this.clickNow-1])
this.ball_Array[this.clickNow-1].getChildByName("guang").active = false;
if(this.clickNow == this.now_Array.length){
this.pause = true;
cc.fx.GameConfig.GM_INFO.total += this.clickNow;
this.overTime = cc.fx.GameTool.getTime();
if(this.startTime > 0 && this.overTime > 0){
cc.fx.GameConfig.GM_INFO.mean_Time += (this.overTime - this.startTime);
}
let finish_time = parseInt((this.overTime - this.startTime)/100+"");
this.startTime = 0; this.overTime = 0;
let color = "y";
if(this.level < 4 && this.level > 1)color = "yr";
else if(this.level >= 4) color = "yrb";
let win = this.node.getChildByName("Win");
win.active = true; win.setScale(0);
cc.fx.AudioManager._instance.playWin();
this.round += 1;
let sunArray = [];
if(this.moveArray.length > 0){
for(let m=0 ; m<this.moveArray.length;m++){
if(m == this.repeat || m == this.numberRepeat){
this.moveArray[m] = 2;
}
sunArray.push(this.moveArray[m]);
}
}
else{
for(let m=0 ; m<this.ball_Array.length;m++){
if(m == this.repeat || m == this.numberRepeat){
sunArray.push(2);
}
else
sunArray.push(0);
}
}
cc.fx.GameConfig.CLICK_DATA =
{
type:1,
success:true,
round:this.round,
totalSunCount:this.now_Array.length,
movedSunCount:cc.fx.GameConfig.LEVEL_INFO[this.level-1].moveNumber,
sunSpeed:cc.fx.GameConfig.LEVEL_INFO[this.level-1].moveSpeed,
duration:finish_time/10,
difficultyLevel:this.level,
sunList:sunArray,
stepTimeList:this.time_Array,
remainder:this.countTime
}
if(cc.fx.GameConfig.CLICK_DATA.duration > 50){
cc.fx.GameConfig.CLICK_DATA.duration = 50;
}
this.setData();
cc.tween(win)
.delay(0.4)
.to(0.01,{scale:2.5})
.to(0.35,{scale:1})
.delay(0.4)
.call(() =>{
win.active = false;
this.destroyLine();
if(this.over == false && this.countTime >= 0){
if(this.level >= 15){
cc.fx.GameConfig.GM_INFO.success = true;
this.level += 0;
// this.levelLabel.string = this.level + "";
this.fuhuo = true;
this.passLevel();
}
else{
this.level += 1;
// this.levelLabel.string = this.level + "";
this.fuhuo = true;
this.passLevel();
}
}
})
.start();
}
}
else{
this.setLoss();
}
}
}
//执行失败
setLoss(){
cc.fx.AudioManager._instance.playWarning();
this.begin = false;
this.overTime = cc.fx.GameTool.getTime();
if(this.startTime > 0 && this.overTime > 0){
cc.fx.GameConfig.GM_INFO.mean_Time += (this.overTime - this.startTime);
}
let finish_time = parseInt((this.overTime - this.startTime)/100+"");
if(finish_time > 58) finish_time = 58;
this.startTime = 0; this.overTime = 0;
let color = "y";
if(this.level < 4 && this.level > 1)color = "yr";
else if(this.level >= 4) color = "yrb";
this.round += 1;
let sunArray = [];
if(this.moveArray.length > 0){
for(let m=0 ; m<this.moveArray.length;m++){
if(m == this.repeat || m == this.numberRepeat){
this.moveArray[m] = 2;
}
sunArray.push(this.moveArray[m]);
}
}
else{
for(let m=0 ; m<this.ball_Array.length;m++){
if(m == this.repeat || m == this.numberRepeat){
sunArray.push(2);
}
else
sunArray.push(0);
}
}
cc.fx.GameConfig.CLICK_DATA =
{
type:1,
success:false,
round:this.round,
totalSunCount:this.now_Array.length,
movedSunCount:cc.fx.GameConfig.LEVEL_INFO[this.level-1].moveNumber,
sunSpeed:cc.fx.GameConfig.LEVEL_INFO[this.level-1].moveSpeed,
duration:finish_time/10,
difficultyLevel:this.level,
sunList:sunArray,
stepTimeList:this.time_Array,
remainder:this.countTime
}
if(cc.fx.GameConfig.CLICK_DATA.duration > 50){
cc.fx.GameConfig.CLICK_DATA.duration = 50;
}
this.setData();
if(this.fuhuo == true){
this.fuhuo = false;
this.loseLevel(1);
}
else{
if(this.level > 2){
this.level -= 1;
// this.levelLabel.string = this.level + "";
this.fuhuo = true;
// this.fuhuo = false;
this.loseLevel(2);
}
else{
this.loseLevel(1);
}
}
let over = this.node.getChildByName("Over");
cc.tween(over)
.to(0.25,{opacity:255})
.delay(0.1)
.to(0.2,{opacity:0})
.delay(0.1)
.to(0.15,{opacity:255})
.delay(0.1)
.to(0.1,{opacity:0})
.start();
}
//开始游戏
startGame(){
if(this.over == false && this.countTime > 0){
this.pause = true;
this.createSun();
this.begin = false;
cc.tween(this.ball)
.to(0.5,{opacity:255,scale:1.3})
.start();
}
}
//执行太阳运行动画,以及后面移动动画
runGame(){
let time = -650;
for(let i=0; i<this.now_Array.length; i++){
time = this.now_Array[i].time*1000 + time;
setTimeout(() => {
if(this.over == false){
let temp = this.now_Array[i].timeCount;
if(temp > 0.5) temp = 0.5;
if(i != 0){
if(this.ball && this.now_Array[i]){
this.createLine(cc.v2(this.ball.x,this.ball.y),cc.v2(this.now_Array[i].x,this.now_Array[i].y),
this.now_Array[i].time-temp);
}
}
cc.tween(this.ball)
.to(this.now_Array[i].time-temp,{x:this.now_Array[i].x,y:this.now_Array[i].y})
.to(0.1,{scale:1})
.call(()=>{
this.createBall(i,this.now_Array[i].color,this.now_Array[i].speed,this.now_Array[i].repeat);
if(i == this.now_Array.length -1){
this.ball.opacity = 0;
setTimeout(() => {
this.destroyLine();
this.beginGame();
if(cc.fx.GameConfig.LEVEL_INFO[this.level-1].moveNumber<1){
this.pause = false;
}
else{
this.moveAction();
}
}, 150);
}
})
.start()
}
}, time);
}
}
//设置移动重叠数据
createMove(){
if(this.over == false){
let info = cc.fx.GameConfig.LEVEL_INFO[this.level-1];
//改变移动速度
var speed = 7;
if(info.moveSpeed >= 2){
speed = 7 - info.moveSpeed/2;
}
if(info.repeat == 1){
this.repeat = parseInt((Math.random()*(info.number-1)+1) + "");
let tempNumber = 0;
// this.repeat = 4;
if(this.repeat > 4){
this.numberRepeat = parseInt(Math.random()*4 + "");
if(this.repeat == (info.number-1)) //如果是最后一个 不能跟第一个重叠
this.numberRepeat = this.repeat - parseInt( (Math.random()*3 + 2)+ "")
tempNumber = this.Pos_Array[this.numberRepeat];
this.Pos_Array[this.repeat ] = tempNumber;
}
else{ // 0 1 2 3 4 5
// 6 - 3 - 1 = 2 4 01 4
if(this.repeat == 0) this.repeat = 1;
if((info.number-1-this.repeat ) == 2){
this.numberRepeat = info.number - 1;
tempNumber = this.Pos_Array[this.numberRepeat];
}
else if((info.number-1-this.repeat ) == 1){
this.numberRepeat = this.repeat - 2;
tempNumber = this.Pos_Array[this.numberRepeat];
}
else if((info.number-1-this.repeat ) == 0){
this.numberRepeat = this.repeat - 2;
tempNumber = this.Pos_Array[this.numberRepeat];
}
else if((info.number-1-this.repeat ) > 2){
this.numberRepeat = parseInt(Math.random()*(info.number-this.repeat -2) + "") + this.repeat + 2 ;
tempNumber = this.Pos_Array[this.numberRepeat];
}
else{
this.numberRepeat = this.repeat - 2;
tempNumber = this.Pos_Array[this.numberRepeat];
}
this.Pos_Array[this.repeat] = tempNumber;
}
}
if(info.moveNumber > 0){
//0 1 2 3 4 5 6 7 8 9
//可移动区分
let pos = cc.v2(0,0);
for(let z=0; z<info.number; z++){
this.moveArray[z] = 0;
}
for(let p=0; p<info.moveNumber; p++){
this.moveArray[info.number-1-p] = 1;
}
let timeOut = 0;
//打乱可移动顺序
this.moveArray.sort(() => Math.random() - 0.5);
if(this.moveArray[0] == 1){
for(let r=info.number-1; r>=0; r--){
if(this.moveArray[r] == 0){
this.moveArray[r] = 1;
this.moveArray[0] = 0;
r = -1;
}
}
}
//将重叠的设置为不可移动 1 1 1 1 0 0 1 0 0 0 / 2 7
for(let k =0; k<this.moveArray.length;k++){
if(this.moveArray[k]==1 && (k == this.repeat || k == this.numberRepeat)){
for(let m = this.moveArray.length-1; m >= 0; m--){
if(m != k && this.moveArray[m] == 0 && m!= this.repeat && m!= this.numberRepeat){
this.moveArray[m] = 1;
this.moveArray[k] = 0;
m = -1;
}
}
}
}
for(let i =0; i<this.Pos_Array.length;i++){
if(this.moveArray [i] == 1){
timeOut += 1;
setTimeout(() => {
pos = this.getPos2(true,i);
this.Pos_Array[i] = pos;
}, timeOut*300);
}
}
}
}
}
//移动后数据 重新刷一遍赋值
updateArray(){
for(let i=0; i<this.now_Array.length-1;i++){
this.now_Array[i].x = this.Pos_Array[i].x;
this.now_Array[i].y = this.Pos_Array[i].y;
}
}
//太阳初始化后移动方法
moveAction(){
this.updateArray();
let moveArray = this.moveArray;
let info = cc.fx.GameConfig.LEVEL_INFO[this.level-1];
//改变移动速度
var speed = 7;
if(info.moveSpeed >= 2){
speed = 7 - info.moveSpeed/2;
}
if(info.moveNumber > 0){
//0 1 2 3 4 5 6 7 8 9
//可移动区分
//将重叠的设置为不可移动 1 1 1 1 0 0 1 0 0 0 / 2 7
for(let k =0; k<this.moveArray.length;k++){
if(this.moveArray[k]==1 && (k == this.repeat || k == this.numberRepeat)){
for(let m = this.moveArray.length-1; m >= 0; m--){
if(m != k && this.moveArray[m] == 0 && m!= this.repeat && m!= this.numberRepeat){
this.moveArray[m] = 1;
this.moveArray[k] = 0;
m = -1;
}
}
}
}
let lastNumber = 0;
//锁定最后一个可移动的
for(let j =0; j<moveArray.length;j++){
if(moveArray[j]==1){
lastNumber = j;
}
}
for(let i =0; i<this.ball_Array.length;i++){
if(moveArray[i] == 1){
if(i != lastNumber){ //如果不是最后一个移动的
let time = speed*this.calculateDistance(this.ball_Array[i].x,this.ball_Array[i].y,this.Pos_Array[i].x,this.Pos_Array[i].y,3);
this.ball_Array[i].getComponent("Sun").move = true;
cc.tween(this.ball_Array[i])
.to(time,{position:this.Pos_Array[i]})
.call(() =>{
this.ball_Array[i].getComponent("Sun").move = false;
})
.start();
}
//如果是最后一个
else{
let time = speed*this.calculateDistance(this.ball_Array[i].x,this.ball_Array[i].y,this.Pos_Array[i].x,this.Pos_Array[i].y,3);
this.ball_Array[i].getComponent("Sun").move = true;
cc.tween(this.ball_Array[i])
.to(time,{position:this.Pos_Array[i]})
.call(() =>{
this.ball_Array[i].getComponent("Sun").move = false;
})
.start();
}
}
}
}
}
//每次重新开始新一轮儿游戏
beginGame(){
this.begin = true;
this.startTime = cc.fx.GameTool.getTime();
this.timeStart = cc.fx.GameTool.getTime();
this.pause = false;
// this.node.getChildByName("showBtn").active = true;
}
//创建太阳所需数据
createSun(){
let levelData = cc.fx.GameConfig.LEVEL_INFO[this.level-1];
let tiemOut = 0;
for(let l=0; l<levelData.number;l++){
tiemOut += 1;
setTimeout(() => {
if(this.over == false){
let pos = this.getPos(false,l);
this.Pos_Array.push(pos);
if(this.Pos_Array.length == levelData.number){
this.createMove();
this.createPos();
}
}
}, tiemOut*100);
}
}
//创建太阳位置,颜色信息等数据
createPos(){
let data = {x:this.ball.x,y:this.ball.y,time:0,timeCount:0,color:0,speed:0,repeat:false};
let levelData = cc.fx.GameConfig.LEVEL_INFO[this.level-1];
//颜色区分
let colorArray = [0,1];
for(let j=0; j<levelData.number-2;j++){
let colorTemp = parseInt(Math.random()*3+"");
if(levelData.number < 6 && colorTemp == 2) colorTemp = 0;
colorArray.push(colorTemp);
colorArray.sort(() => Math.random() - 0.5);
}
colorArray.sort(() => Math.random() - 0.5);
if(levelData.number == 4) colorArray = [0,0,0,0];
this.color_Array = colorArray;
//存储太阳数据
for(let i=0; i<levelData.number;i++){
let timeCount = this.timeCount + (0.6-this.calculateDistance(this.ball.x,this.ball.y,this.Pos_Array[i].x,this.Pos_Array[i].y,1));
let time = this.calculateDistance(this.ball.x,this.ball.y,this.Pos_Array[i].x,this.Pos_Array[i].y,1)+timeCount;
data = {x:this.Pos_Array[i].x,y:this.Pos_Array[i].y,time:time,timeCount:timeCount,color:colorArray[i],speed:levelData.moveSpeed,repeat:false};
if(this.repeat == i){
data.repeat = true;
}
else if(this.numberRepeat == i){
data.repeat = true;
}
this.now_Array.push(data);
}
this.runGame();
}
//获取N个太阳位置的方法和POS2分开两个方法防止递归溢出
getPos(type,num){
let posX = Math.random()*620 - 310;
let posY = Math.random()*(this.fitTop-this.fitBot) + this.fitBot;
let point = cc.v2(posX,posY);
if(this.Pos_Array.length > 0){
for(let i=0; i<this.Pos_Array.length;i++){
let distance = false;
let pd = false;
if(i == num) pd = true;
distance = this.getDistance(posX,posY,this.Pos_Array[i].x,this.Pos_Array[i].y,pd)
if(distance == false){
i = 10000;
point = this.getPos(type,num);
}
if(distance == true && i == (this.Pos_Array.length-1)){
i = 10000;
}
}
}
return point;
}
//获取N个太阳可移动位置的方法和POS分开算防止递归溢出
getPos2(type,num){
let posX = Math.random()*620 - 310;
let posY = Math.random()*(this.fitTop-this.fitBot) + this.fitBot;
let point = cc.v2(posX,posY);
if(this.Pos_Array.length > 0){
for(let i=0; i<this.Pos_Array.length;i++){
let distance = false;
let pd = false;
if(i == num) pd = true;
distance = this.getDistance2(posX,posY,this.Pos_Array[i].x,this.Pos_Array[i].y,pd)
if(distance == false){
i = 10000;
point = this.getPos2(type,num);
}
if(distance == true && i == (this.Pos_Array.length-1)){
i = 10000;
}
}
}
return point;
}
//获取两点之间距离,返回判断是否在一定范围内 将来提出到工具类
getDistance(x1, y1, x2, y2,num) {
var jg = false;
const dx = x2 - x1;
const dy = y2 - y1;
var distance = Math.sqrt(dx*dx + dy*dy);
if(distance > 160){
if(num == true){
cc.fx.GameConfig
if(distance < cc.fx.GameConfig.LEVEL_INFO[this.level-1].maxMove){
jg = true;
}
else jg = false;
}
else{
if(distance < cc.fx.GameConfig.LEVEL_INFO[this.level-1].maxMove){
jg = true;
}
else jg = false;
}
}
return jg;
}
//命中动画
hitAction(data){
this.hit.active = true; this.hit.opacity = 0;
this.hit.setPosition
this.hit.setPosition(this.ball_Array[data].x+35,this.ball_Array[data].y+35);
cc.tween(this.hit)
.to(0,{opacity:255})
.to(0.2,{position:cc.v3(this.hit.x-35,this.hit.y-35,0)})
.delay(0.2)
.to(0.1,{opacity:0})
.call(() =>{
this.hit.active = false;
})
.start();
}
//创造太阳
createBall(number,color,speed,repeat){
let ball = null;
if(color == 0)ball = cc.instantiate(this.qiu1);
else if(color == 1)ball = cc.instantiate(this.qiu2);
else if(color == 2)ball = cc.instantiate(this.qiu3);
ball.parent = this.node.getChildByName("Sun");
ball.zIndex = this.now_Array.length - number;
ball.setPosition(this.ball.x,this.ball.y);
ball.getComponent("Sun").init(number,color,speed,repeat);
this.ball_Array.push(ball);
}
//销毁连线
destroyLine() {
for(let i =0; i< this.node.getChildByName("Line").children.length;i++){
if(this.node.getChildByName("Line").children[i]){
this.node.getChildByName("Line").children[i].removeFromParent();
this.node.getChildByName("Line").children[i] = null;
}
}
this.node.getChildByName("Line").removeAllChildren();
}
//创建连线
createLine(start,end,time){
let line = cc.instantiate(this.linePrefab);
line.parent = this.node.getChildByName("Line");
line.setPosition(start.x,start.y);
const dx = end.x - start.x;
const dy = end.y - start.y;
var distance = Math.sqrt(dx*dx + dy*dy);
line.height = distance;
line.getComponent(cc.Sprite).fillRange = 0;
line.angle = -this.calculateAngle(start.x,start.y,end.x,end.y);
cc.tween(line.getComponent(cc.Sprite))
.to(time,{fillRange:1})
.start();
}
//获取两点之间的角度,将来都可放工具类
calculateAngle(x1, y1, x2, y2) {
var angle = Math.atan2(y2-y1,x2-x1)*180 / Math.PI - 90;
return -angle;
}
//获取两点之间的距离 返回对应时间
calculateDistance(x1, y1, x2, y2, num) {
const dx = x2 - x1;
const dy = y2 - y1;
let time = 0;
var distance = Math.sqrt(dx*dx + dy*dy);
if(num == 1){
if(distance > 800) distance = 800;
time = distance/800 * 0.6;
}
else if(num == 2){
if(distance > 1200) distance = 1200;
time = distance/1200 * 1;
}
else if(num == 3){
if(distance > 1200) distance = 1200;
time = distance/1200 * 1.5;
}
return time;
}
//获取两点之间距离 返回距离判断
getDistance2(x1, y1, x2, y2,num) {
var jg = false;
const dx = x2 - x1;
const dy = y2 - y1;
var distance = Math.sqrt(dx*dx + dy*dy);
if(distance > 160){
if(num == true){
if(distance < cc.fx.GameConfig.LEVEL_INFO[this.level-1].maxDistance) jg = true;
else jg = false;
}
else{
jg = true;
}
}
return jg;
}
//背景移动
bgMove(type){
let random = Math.random()*300 + 300;
let posX = Math.random()*600 - 300;
let y1 = this.bg1.y - random*type;
let time1 = 0.7*(random/400);
cc.tween(this.ball)
.to(0.3,{scale:1.3})
.to(time1,{x:posX})
.start();
cc.tween(this.bg1)
.delay(0.3)
.to(time1,{y:y1})
.start();
setTimeout(() => {
if(this.over == false) this.startGame();
}, time1*1500);
}
//如果是倒计时 调用此方法
updateCountDownTime () {
if (this.countTime > 0 && this.pause == false) {
this.countTime -= 1;
this.time.string = cc.fx.GameTool.getTimeMargin(this.countTime);
if(this.countTime < 5){
cc.tween(this.time.node)
.to(0.25,{scale:1.5,color:cc.color(255,0,0)})
.to(0.25,{scale:1,color:cc.color(255,255,255)})
.start()
let over = this.node.getChildByName("Over");
cc.tween(over)
.to(0.2,{opacity:255})
.delay(0.1)
.to(0.2,{opacity:0})
.start();
}
if(this.countTime <= 0){
this.begin = false;
this.over = true;
this.unschedule(this.updateCountDownTime);
this.setLoss();
var time = 0;
if(this.clickCount > 0) time = parseInt(cc.fx.GameConfig.GM_INFO.mean_Time/this.clickCount + "");
cc.fx.GameConfig.GM_INFO.mean_Time = parseInt(time/100 + "");
cc.fx.GameConfig.GM_INFO.mean_Time = cc.fx.GameConfig.GM_INFO.mean_Time /10;
if(time > 10000) time = (Math.random()*10+5)*100;
this.gameOver(time);
}
}
}
//上传每次操作数据
setData(){
cc.fx.GameTool.setGameData();
}
//上传排行榜数据
gameOver(time){
cc.fx.GameTool.setRank(time);
this.node.getChildByName("GameOver").active = true;
this.node.getChildByName("GameOver").opacity = 0;
cc.tween(this.node.getChildByName("GameOver"))
.to(0.4,{opacity:255})
.delay(2)
.to(0.4,{opacity:50})
.call(() =>{
cc.director.loadScene("OverScene");
})
.start()
}
//作弊,测试用
showNumber(){
if(this.show == false) this.show = true;
else if(this.show == true) this.show = false;
for(let i=0; i<this.ball_Array.length; i++){
this.ball_Array[i].getComponent("Sun").showNumber(this.show);
}
}
onEnable () {
cc.fx.Notifications.on("clickSun", this.clickSun, this);
}
onDisable () {
cc.fx.Notifications.off("clickSun", this.clickSun);
}
update (dt) {
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "b0432040-dbde-438c-839c-ba2b5d18a3b5",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

126
assets/Script/GameOver.ts Normal file
View File

@ -0,0 +1,126 @@
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
count: cc.Label = null;
@property(cc.Label)
time: cc.Label = null;
@property(cc.Node)
selfNode: cc.Node = null;
@property(cc.Node)
one: cc.Node = null;
@property(cc.Node)
two: cc.Node = null;
@property(cc.Node)
three: cc.Node = null;
@property(cc.Node)
four: cc.Node = null;
@property(cc.Node)
five: cc.Node = null;
listData: any;
selfData: any;
// onLoad () {}
start () {
this.count.string = cc.fx.GameConfig.GM_INFO.total + "";
if(cc.fx.GameConfig.GM_INFO.mean_Time > 10){
cc.fx.GameConfig.GM_INFO.mean_Time = (parseInt(Math.random()*10+"")+5)/10
}
this.time.string = cc.fx.GameConfig.GM_INFO.mean_Time + "s";
this.init();
}
//初始化数据
init(){
this.listData = [];
this.selfData = null;
this.one.active = false;
this.two.active = false;
this.three.active = false;
this.four.active = false;
this.five.active = false;
var urlNow = window.location.href;
if(this.containsTrain(urlNow)){
this.node.getChildByName("again").active = false;
this.node.getChildByName("back").active = false;
this.node.getChildByName("finishi").active = true;
this.setLocalStorage();
}
else{
this.node.getChildByName("again").active = true;
this.node.getChildByName("back").active = true;
this.node.getChildByName("finishi").active = false;
}
this.getRank();
}
setLocalStorage(){
const today = new Date().toLocaleDateString();
var name = `success_${today}_${cc.fx.GameConfig.GM_INFO.scode}_${cc.fx.GameConfig.GM_INFO.gameId}`
localStorage.setItem(name, JSON.stringify({success:true}));
}
//打开排行榜
jumpFinishi(){
let url = "https://train.sparkus.cn/poster/game/" + cc.fx.GameConfig.GM_INFO.scode + "?suc=1";
window.location.href = url;
}
//打开排行榜
openRank(){
cc.director.loadScene("RankScene");
}
//重新开始玩
again(){
cc.director.loadScene("GameScene");
}
//判断来源
containsTrain(str) {
return /from=train/i.test(str);
}
//获取排行榜
getRank(){
//获取排行榜数据 所需数据量
let dataFile = {
length:5
}
cc.fx.GameTool.getRank(dataFile,data =>this.getRankData(data));
}
//设置排行信息
getRankData(data){
if(data){
cc.fx.GameTool.getRankData(data,this,4);
cc.fx.GameTool.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"),this.selfData.pic);
for(let i=0;i<=4;i++){
this.setRank(i,this.listData[i]);
}
}
}
//根据内容填充排行榜
setRank(num,data){
if(!data){
return;
}
var hitNode = null;
if(num == 0){
hitNode = this.one;
}
else if(num == 1){
hitNode = this.two;
}
else if(num == 2){
hitNode = this.three;
}
else if(num == 3){
hitNode = this.four;
}
else if(num == 4){
hitNode = this.five;
}
if(hitNode){
hitNode.active = true;
cc.fx.GameTool.subName(data.nickName,4);
hitNode.getChildByName("name").getComponent(cc.Label).string = data.nickName;
hitNode.getChildByName("total").getComponent(cc.Label).string = data.totalSunCount;
cc.fx.GameTool.setPic(hitNode.getChildByName("pic").getChildByName("icon"),data.pic);
}
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "805c69df-dfdf-4759-97ae-5a7341f424c7",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,307 @@
//此页面为引导页面,后续更新成模板,暂时偷懒复制主游戏场景代码进来
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
// LIFE-CYCLE CALLBACKS:
@property(cc.Node)
dialog: cc.Node = null;
@property(cc.Node)
ball: cc.Node = null;
@property(cc.Prefab)
qiu1: cc.Prefab = null;
@property(cc.Prefab)
linePrefab: cc.Prefab = null;
clickNow:number;
custom: number;
Pos_Array: any;
ball_Array: any;
begin: boolean;
tip: cc.Node;
// onLoad () {}
start () {
cc.fx.GameConfig.GM_INFO.custom = 0;
this.init();
this.startGuide(0);
}
//初始化数据
init(){
this.custom = 1;
this.ball.zIndex = 100;
this.Pos_Array = [];
this.ball_Array = [];
this.begin = false;
this.clickNow = 0;
this.tip = null;
}
//开始引导方法
startGuide(type){
let num = this.custom;
let time = 0.5;
let name = "tip" + num;
if(type!=0){
cc.tween(this.node)
.to(time,{opacity:255})
.call(() =>{
this.custom += 1;
if(type != 0) this.custom = 2;
if( this.custom == 2) this.createSun(true);
else if( this.custom == 3) this.createSun(false);
else if( this.custom == 4) this.begin = true;
else if( this.custom == 5) cc.director.loadScene("GameScene");
})
.start();
}
else{
this.tip = this.dialog.getChildByName(name);
this.tip.active = true; this.tip.opacity = 0;
cc.tween(this.tip)
.to(time,{opacity:255})
.start();
}
}
//清除所有太阳
beginClick(){
for(let i=0; i<this.ball_Array.length; i++){
this.ball_Array[i].getComponent("Sun").move = false;
}
}
//点击开始游戏,或者点击跳过引导
clickBtn(){
cc.director.loadScene("GameScene");
}
//点击下一步按钮
next(){
let time = 0.5;
cc.tween(this.tip)
.to(time,{opacity:0})
.call(() =>{
this.custom += 1;
if( this.custom == 2) this.createSun(true);
else if( this.custom == 3) this.createSun(false);
else if( this.custom == 4) this.begin = true;
else if( this.custom == 5) cc.director.loadScene("GameScene");
})
.start();
}
//创建太阳
createSun(type){
if(type == true){
this.ball_Array = [];
this.Pos_Array.push(cc.v2(-250,-216),cc.v2(200,-115),cc.v2(-35,-500));
let time1 = this.calculateDistance(this.ball.x,this.ball.y,this.Pos_Array[0].x,this.Pos_Array[0].y)
this.ball.opacity = 0;
cc.tween(this.ball)
.to(time1,{position:this.Pos_Array[0]})
.call(() =>{
this.createBall(0,0,0,false);
})
.delay(1)
.call(() =>{
this.startGuide(0);
})
.start();
}
else{
let time2 = this.calculateDistance(this.Pos_Array[0].x,this.Pos_Array[0].y,this.Pos_Array[1].x,this.Pos_Array[1].y)
let time3 = this.calculateDistance(this.Pos_Array[1].x,this.Pos_Array[1].y,this.Pos_Array[2].x,this.Pos_Array[2].y)
this.ball.opacity = 255;
this.createLine(cc.v2(this.ball.x,this.ball.y),cc.v2(this.Pos_Array[1].x,this.Pos_Array[1].y),
0.5);
cc.tween(this.ball)
.to(time2,{position:this.Pos_Array[1]})
.call(() =>{
this.createBall(1,0,0,false);
})
.delay(0.5)
.call(() =>{
this.createLine(cc.v2(this.ball.x,this.ball.y),cc.v2(this.Pos_Array[2].x,this.Pos_Array[2].y),
0.5);
})
.to(time3,{position:this.Pos_Array[2]})
.call(() =>{
this.createBall(2,0,0,false);
this.ball.opacity = 0;
})
.delay(0.2)
.call(() =>{
this.destroyLine();
this.startGuide(0);
})
.start();
}
}
//创建太阳
createBall(number,color,speed,repeat){
let ball = null;
ball = cc.instantiate(this.qiu1);
ball.parent = this.node.getChildByName("Sun");
ball.zIndex = this.Pos_Array.length - number;
ball.setPosition(this.ball.x,this.ball.y);
ball.getComponent("Sun").init(number,color,speed,repeat);
ball.getComponent("Sun").move = true;
this.ball_Array.push(ball);
}
//获取两点之间角度创建连线用
calculateDistance(x1, y1, x2, y2) {
const dx = x2 - x1;
const dy = y2 - y1;
var distance = Math.sqrt(dx*dx + dy*dy);
if(distance > 800) distance = 800;
const time = distance/800 * 0.8;
return time;
}
//引导成功
passLevel(){
let win = this.node.getChildByName("Win");
win.active = true; win.setScale(0);
cc.tween(win)
.delay(0.4)
.to(0.01,{scale:2.5})
.to(0.35,{scale:1})
.delay(0.6)
.call(() =>{
win.active = false;
setTimeout(() => {
this.destroyLine();
let timeArray = [];
let timeCount = 0;
let ball = this.ball_Array[0];
for(let i=1; i< this.ball_Array.length; i++){
let time = this.calculateDistance(this.ball_Array[i].x,this.ball_Array[i].y,
this.ball_Array[i-1].x,this.ball_Array[i-1].y);
timeArray.push(time);
}
for(let k=1; k< this.ball_Array.length; k++){
setTimeout(() => {
cc.tween(ball)
.to(timeArray[k-1],{x:this.ball_Array[k].x,y:this.ball_Array[k].y})
.call(() =>{
this.ball_Array[k].active = false;
if(k == this.ball_Array.length-1){
setTimeout(() => {
this.ball.opacity = 255;
this.ball.position = cc.v3(ball.x,ball.y,0);
this.ball.active = false;
this.startGuide(0);
}, 200);
}
})
.start();
}, timeCount*1000);
timeCount += (timeArray[k-1]+0.1);
}
}, 400);
})
.start();
}
//点击太阳执行方法
clickSun(data){
if(this.begin == true){
if(data == this.clickNow){
cc.fx.AudioManager._instance.playAudioButton();
if(this.clickNow > 0){
this.createLine(cc.v2(this.ball_Array[this.clickNow-1].x,this.ball_Array[this.clickNow-1].y),
cc.v2(this.ball_Array[this.clickNow].x,this.ball_Array[this.clickNow].y),
0.2);
}
this.clickNow += 1;
cc.fx.GameConfig.GM_INFO.total += 1;
setTimeout(() => {
if(this.ball_Array[this.clickNow-1])
this.ball_Array[this.clickNow-1].getChildByName("guang").active = false;
}, 200);
if(this.clickNow == 3){
this.passLevel();
}
}
else{
this.loseLevel();
}
}
}
//失败事件
loseLevel(){
this.begin = false;
cc.fx.AudioManager._instance.playWarning();
this.destroyLine();
let ball = this.ball_Array[0];
for(let k=1; k< this.ball_Array.length; k++){
cc.tween(this.ball_Array[k])
.to(0.6,{x:ball.x,y:ball.y})
.call(() =>{
this.ball_Array[k].active = false;
if(k == this.ball_Array.length-1){
this.ball.opacity = 0;
this.ball.position = cc.v3(ball.x,ball.y,0);
this.clearSun();
this.custom = 1;
this.startGuide(1);
}
})
.start()
}
//结束页面动画
let over = this.node.getChildByName("Over");
cc.tween(over)
.to(0.25,{opacity:255})
.delay(0.1)
.to(0.2,{opacity:0})
.delay(0.1)
.to(0.15,{opacity:255})
.delay(0.1)
.to(0.1,{opacity:0})
.start();
}
//点击太阳事件
clearSun(){
for(let k=0; k< this.ball_Array.length; k++){
this.ball_Array[k].removeFromParent();
this.ball_Array[k] = null;
}
this.ball_Array = [];
}
//创造连线,参数起点,终点,连线时间
createLine(start,end,time){
let line = cc.instantiate(this.linePrefab);
line.parent = this.node.getChildByName("Line");
line.setPosition(start.x,start.y);
const dx = end.x - start.x;
const dy = end.y - start.y;
var distance = Math.sqrt(dx*dx + dy*dy);
line.height = distance;
line.getComponent(cc.Sprite).fillRange = 0;
line.angle = -this.calculateAngle(start.x,start.y,end.x,end.y);
cc.tween(line.getComponent(cc.Sprite))
.to(time,{fillRange:1})
.start();
}
//摧毁连线
destroyLine() {
for(let i =0; i< this.node.getChildByName("Line").children.length;i++){
if(this.node.getChildByName("Line").children[i]){
this.node.getChildByName("Line").children[i].removeFromParent();
this.node.getChildByName("Line").children[i] = null;
}
}
this.node.getChildByName("Line").removeAllChildren();
}
//获取两个点之间的角度 用于写连线 确定连线方向
calculateAngle(x1, y1, x2, y2) {
var angle = Math.atan2(y2-y1,x2-x1)*180 / Math.PI - 90;
return -angle;
}
onEnable () {
cc.fx.Notifications.on("clickSun", this.clickSun, this);
}
onDisable () {
cc.fx.Notifications.off("clickSun", this.clickSun);
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "3fd2f87a-bc73-4978-8494-8b35b4f716ad",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

43
assets/Script/Load.ts Normal file
View File

@ -0,0 +1,43 @@
import { WeChat } from "./module/Share/share";
const {ccclass, property, requireComponent} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
start () {
window.initMgr();
// WeChat.setShare(location.href);
cc.fx.GameConfig.init();
// cc.fx.AudioManager._instance.init();
var urlNow = window.location.href;
if(this.containsTrain(urlNow)){
console.log("无排行版本");
this.node.getChildByName("Rank").active = false;
}
else{
console.log("有排行版本");
}
}
//判断来源
containsTrain(str) {
return /from=train/i.test(str);
}
//开始游戏,跳转至引导页面
startGame(){
cc.director.loadScene("GuideScene");
}
//备用,用来测试跳转 指定关卡
clickBtn(event,data){
cc.fx.GameConfig.GM_INFO.custom = parseInt(data);
cc.director.loadScene("GameScene");
}
//打开排行榜
openRank(){
cc.director.loadScene("RankScene");
}
protected update(dt: number): void {
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "454ad829-851a-40ea-8ab9-941e828357ca",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,135 @@
import List from "./module/RankList/List";
const { ccclass, property } = cc._decorator;
//排行榜
@ccclass
export default class RankManager extends cc.Component {
@property(cc.Node) //用户上方头像
Player: cc.Node = null;
@property(cc.Node) //用户最下方个人信息
selfNode: cc.Node = null;
@property(cc.Sprite) //用户头像换图
phone: cc.Sprite = null;
private rankList: List; //排行榜
tween: cc.Tween<cc.Node>; //最上方用户头像动画
listData: any; //总列表信息
selfData: any; //自己信息
rankNumber: number; //用户自己排名 有可能不在排行榜内99+
rankTotal: number; //获取排行榜用户数量 现在为100
onLoad() {
this.init();
}
//初始化数据
init(){
this.rankList = cc.find("ScrollView", this.node).getComponent(List);
this.Player.getChildByName("rank").active = false;
this.listData = [];
this.selfData = null;
this.rankNumber = 100;
this.rankTotal= 100;
this.selfNode.opacity = 0;
}
start() {
this.Player.active = false;
this.getRank();
}
//调用获取排行榜接口
getRank(){
let dataFile = {
length:100
}
cc.fx.GameTool.getRank(dataFile,data =>this.getRankData(data));
}
//实际设置排行数据
getRankData(data){
if(data){
console.log(data);
cc.fx.GameTool.getRankData(data,this,6);
this.setPic(this.selfData.pic);
}
}
//返回按钮
backClick(){
cc.director.loadScene("LoadScene");
}
//最上方用户动画
playerAction(){
//-254 377 210 453
this.Player.getChildByName("rank").active = false;
let time = 0;
this.tween = cc.tween(this.Player)
.to(2,{position:cc.v3(210,453,0)})
.call(() =>{
this.Player.getChildByName("rank").active = true;
this.Player.getChildByName("rank").getChildByName("number")
.getComponent(cc.Label).string = parseInt(time*100 + "") + "%";
})
.start();
if(this.listData.length > 0){
time = (this.listData.length - this.rankNumber)/this.listData.length;
}
if(this.listData.length >= 99){
if(this.rankNumber >= 99){
time = (Math.random()*49+1)/100
var matchId = cc.sys.localStorage.getItem("matchNumber");
if(matchId == null || matchId == undefined){
time = 0;
}
}
}
setTimeout(() => {
if(this.tween)this.tween.stop();
this.Player.getChildByName("rank").active = true;
this.Player.getChildByName("rank").getChildByName("number")
.getComponent(cc.Label).string = parseInt(time*100 + "") + "%";
}, time*2000);
}
//设置头像 处理的逻辑比较多,不用公共类的了
public setPic(pic){
this.phone.node.parent.getChildByName("icon").active = false;
this.phone.node.active = false;
this.Player.active = true;
this.Player.opacity = 0;
this.Player.getChildByName("mask").getChildByName("icon").active = false;
this.Player.getChildByName("mask").getChildByName("phone").active = false;
fetch(pic)
.then(response => {
return response.headers.get('Content-Length');
})
.then(errNo => {
if(errNo == "5093"){
this.phone.node.parent.getChildByName("icon").active = true;
this.Player.getChildByName("mask").getChildByName("icon").active = true;
}
})
.catch(error => {
// console.error('Error fetching X-Info:', error);
});
var self = this;
cc.assetManager.loadRemote(pic, {ext:'.png'},(err, texture:cc.Texture2D) => {
self.Player.opacity = 255;
if(texture){
self.phone.node.active = true;
self.phone.spriteFrame = new cc.SpriteFrame(texture);
self.Player.getChildByName("mask").getChildByName("icon").active = false;
self.Player.getChildByName("mask").getChildByName("phone").active = true;
self.Player.getChildByName("mask").getChildByName("phone").getComponent(cc.Sprite)
.spriteFrame = new cc.SpriteFrame(texture);
setTimeout(() => {
self.playerAction();
}, 500);
}
else{
self.Player.getChildByName("mask").getChildByName("icon").active = true;
setTimeout(() => {
self.playerAction();
}, 500);
}
})
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "e74a9f7d-2031-4e69-bcb2-9998174088b2",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

73
assets/Script/Sun.ts Normal file
View File

@ -0,0 +1,73 @@
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
id_Number:number
_speed:number
_color:number
touch:boolean
_repeat:boolean
move:boolean
// onLoad () {}
start () {
}
//初始化数据
init(_id,color,speed,repeat){
this.touch = true;
this.move = false;
this.id_Number = _id;
this._color = color;
this._speed = speed;
this._repeat = repeat;
//太阳动画
cc.tween(this.node.getChildByName("shan"))
.repeatForever(
cc.tween()
.to(1,{opacity:0,scale:0.5,})
.delay(0.2)
.to(1,{opacity:255,scale:1.2})
.delay(0.5)
)
.start();
}
//用于作弊 测试
showNumber(type){
this.node.getChildByName("number").active = type;
if(type == true)
this.node.getChildByName("number").getComponent(cc.Label).string = this.id_Number + "";
}
//点击事件
clickBtn(event,data){
if(data === "1"){
if( this.move == false && this.touch == true){
if(this.node.parent.parent.name == "GameNode"){
if(this.node.parent.parent.getComponent("GameManager").begin == true){
cc.tween(this.node.getChildByName("action"))
.to(0.5,{opacity:0,scale:1.8})
.start();
cc.tween(this.node)
.to(0.3,{scale:1.3})
.to(0.3,{scale:1})
.start();
this.touch = false;
this.node.zIndex = -1;
cc.fx.Notifications.emit("clickSun",this.id_Number);
}
}
else{
this.touch = false;
this.node.zIndex = -1;
cc.fx.Notifications.emit("clickSun",this.id_Number);
}
}
}
else{
if( this.touch == true && this.node.parent.parent.getComponent("GuideManager").begin == true){
this.touch = false;
this.node.zIndex = -1;
cc.fx.Notifications.emit("clickSun",this.id_Number);
}
}
}
}

10
assets/Script/Sun.ts.meta Normal file
View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "4be67b1d-91ec-42ca-a2e5-d0d1ddf4dd5f",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/Script/module.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "eaa8b84d-69d0-4170-9f7d-8179ea948cde",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "8848cd9b-8115-456d-a656-2abcda1dadbe",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,363 @@
import { WeChat } from "../Share/share";
const { ccclass, property } = cc._decorator;
@ccclass('GameConfig')
export class GameConfig {
//所有控制信息都通过GameAppStart内控制
private static _instance : GameConfig = null;
//用于盛放埋点数据上传,每次上传后清空
static LEVEL_INFO: { //第一难度
number: number; //太阳总数
moveNumber: number; //太阳可移动个数
moveSpeed: number; //太阳移动速度等级
maxDistance: number; //布局后移动最大距离
maxMove: number; //每个太阳之间距离最大间距
repeat: number; //是否重叠现在0 不重叠 1 重叠1个
}[];
static GAME_DATA: any[];
static GM_INFO: {
// isEnd: false,
mean_Time: number; //平均放箭速度
total: number; //总共对的个数
currSeed: number; //用于随机数种子
gameId: string; //游戏ID
userId: number; //用户ID
scode: string; //用户code,从网页后缀获取
guide: boolean; //是否有引导
url: string; //访问域名
success: boolean; //用户游戏成功与否
matchId: any; //用于埋点上传的ID
custom: number; //用于测试跳关卡
gap: any[]; //存储点击到太阳中心距离
};
static CLICK_DATA: {
type: number; //上传数据类型
success: boolean; //此局游戏胜负
round: number; //回合数
totalSunCount: number; //太阳总数
movedSunCount: number; //可移动太阳个数
sunSpeed: number; //太阳移动速度
duration: number; //每次点击的反应时间
difficultyLevel: number; //此次难度
sunList: any[]; //太阳数组,用于存放太阳类型 0:普通 1:移动 2:重叠
stepTimeList: any[]; //每次点击间隔
remainder: number; //游戏剩余时间
gap: any[]; //点击到太阳中心距离
};
static get Instance()
{
if (this._instance == null)
{
this._instance = new GameConfig();
}
return this._instance;
}
static getKey(key){
var reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return "";
}
static init(){
this.GM_INFO_init();
this.CLICK_init();
this.LEVEL_INFO_init();
var self = this;
// cc.resources.load('Json/GM_INFO', (err: any, res: cc.JsonAsset) => {
// if (err) {
// // @ts-ignore
// if(window.wx !== null && window.wx !== undefined) WeChat.setShare(location.href);
// // self.Authentication();
// return;
// }
// let jsonData: object = res.json!;
// self.GM_INFO = jsonData["data"];
// self.setCode(self.getKey("scode"));
// // @ts-ignore
// if(window.wx !== null && window.wx !== undefined) WeChat.setShare(location.href);
// // self.Authentication();
// })
// cc.resources.load('Json/CLICK_DATA', (err: any, res: cc.JsonAsset) => {
// if (err) {
// return;
// }
// let jsonData: object = res.json!;
// self.CLICK_DATA = jsonData["data"];
// })
// cc.resources.load('Json/LEVEL_INFO', (err: any, res: cc.JsonAsset) => {
// if (err) {
// return;
// }
// let jsonData: object = res.json!;
// self.LEVEL_INFO = jsonData["data"];
// })
//GAME_DATA 废弃了,暂时不删除以防后面修改回 一整局传一次
self.GAME_DATA = [
]
}
//数据备用
static GM_INFO_init() {
this.GM_INFO = {
// isEnd: false,
mean_Time: 0, //平均放箭速度
total: 0, //总共对的个数
currSeed: 203213, //用于随机数种子
gameId: '100015', //游戏ID
userId: 0, //用户ID
scode: "", //用户code,从网页后缀获取
guide: true, //是否有引导
url: "https://api.sparkus.cn",//访问域名
success: false, //用户游戏成功与否
matchId: null, //用于埋点上传的ID
custom: 0, //用于测试跳关卡
gap:[] //存储点击到太阳中心距离
};
this.setCode(this.getKey("scode"));
WeChat.setShare(location.href);
this.Authentication();
}
static CLICK_init() {
this.CLICK_DATA =
{
type: 1, //上传数据类型
success: false, //此局游戏胜负
round: 0, //回合数
totalSunCount: 0, //太阳总数
movedSunCount: 0, //可移动太阳个数
sunSpeed: 0, //太阳移动速度
duration: 0, //每次点击的反应时间
difficultyLevel: 0, //此次难度
sunList: [], //太阳数组,用于存放太阳类型 0:普通 1:移动 2:重叠
stepTimeList: [], //每次点击间隔
remainder: 120, //游戏剩余时间
gap:[] //点击到太阳中心距离
}
}
static LEVEL_INFO_init() {
this.LEVEL_INFO = [
{ //第一难度
number: 3, //太阳总数
moveNumber: 0, //太阳可移动个数
moveSpeed: 0, //太阳移动速度等级
maxDistance: 200, //布局后移动最大距离
maxMove: 1200, //每个太阳之间距离最大间距
repeat: 0 //是否重叠现在0 不重叠 1 重叠1个
},
{ //第二难度
number: 4,
moveNumber: 0,
moveSpeed: 0,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第三难度
number: 4,
moveNumber: 0,
moveSpeed: 0,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第四难度
number: 5,
moveNumber: 1,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第五难度
number: 5,
moveNumber: 0,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第六难度
number: 6,
moveNumber: 0,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第七难度
number: 6,
moveNumber: 3,
moveSpeed: 4,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第八难度
number: 7,
moveNumber: 0,
moveSpeed: 4,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第九难度
number: 7,
moveNumber: 3,
moveSpeed: 4,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第十难度
number: 7,
moveNumber: 3,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第十一难度
number: 8,
moveNumber: 3,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第十二难度
number: 8,
moveNumber: 5,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第十三难度
number: 9,
moveNumber: 3,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第十四难度
number: 9,
moveNumber: 5,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //第十五难度
number: 10,
moveNumber: 5,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //11
number: 3,
moveNumber: 0,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //12
number: 4,
moveNumber: 0,
moveSpeed: 0,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //13
number: 4,
moveNumber: 1,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //14
number: 4,
moveNumber: 0,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //15
number: 4,
moveNumber: 1,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //16
number: 5,
moveNumber: 1,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //17
number: 5,
moveNumber: 0,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //18
number: 5,
moveNumber: 1,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //19
number: 5,
moveNumber: 2,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
},
{ //20
number: 5,
moveNumber: 3,
moveSpeed: 6,
maxDistance: 200,
maxMove: 1200,
repeat: 0
}
]
}
static Authentication(){
cc.fx.GameTool.Authentication();
}
static setCode(code){
this.GM_INFO.scode = code;
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "c5692be7-8703-45e4-9f67-23b54d290356",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "13a0b173-d59e-4a9d-b5e3-4dbe4dc37cc1",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,245 @@
const {ccclass, property} = cc._decorator;
import CryptoJS = require('./crypto-js.min.js'); //引用AES源码js
const BASE_URL = "https://api.sparkus.cn";
//只负责网络接口 次类只负责和后端交互,不负责处理数据 数据处理在GameTool
@ccclass
export default class HttpUtil extends cc.Component {
//排行榜
static async rankData(type,callback,data): Promise<any> {
const time = Math.floor((new Date().getTime()) / 1000)
const url = HttpUtil.apiSign(`/api/get/rank/data?gameId=${config.gameId}&dataType=${type}&time=${time}`, data)
this.post(url,data,callback,0);
}
static async uploadUserLogData(data,callback): Promise<any> {
const url = '/log/collect/data';
this.post(url,data,callback,3);
}
//暂时用不到
static async getUserRecord(data,callback): Promise<any> {
const time = Math.floor((new Date().getTime()) / 1000)
const url = HttpUtil.apiSign(`/api/get/user/data?gameId=${config.gameId}&time=${time}`, data)
this.post(url,data,callback,0);
}
static async get(url, callback,count) {
let repeat = count?count:0;
const response = await this.fetchData(url, null, 'GET',repeat);
callback && callback(response);
}
static async post(url, data, callback,count) {
let repeat = count?count:0;
const response = await this.fetchData(url, data, 'POST',repeat);
callback && callback(response);
}
static async fetchData(url, data, method,repeat) {
const fullUrl = `${BASE_URL}${url}`;
const headers = { 'Content-Type': 'application/json' };
const options = {
method,
headers,
body: data ? JSON.stringify(data) : null,
};
try {
var response = await this.fetchWithTimeout(fullUrl,options);
if (!response.ok) {
throw new Error(`HTTP_______________error! status: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error('Fetch_______________error:', error);
if(repeat > 0){
repeat -= 1;
const timeOut = (3-repeat)*5000;
setTimeout(async () => {
response = await this.fetchData(url, data, method,repeat);
}, timeOut);
}
else{
return null;
}
}
}
static async fetchWithTimeout(resource, options = {}) {
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), 5000);
const response = await fetch(resource, {
...options,
signal: controller.signal
});
clearTimeout(id);
return response;
}
/**
*
* @param url {string}
* @param params {object}
*/
static apiSign(url: string, params = {}) {
let convertUrl = url.trim()
if (convertUrl.indexOf('?') === -1) {
convertUrl += '?'
}
// 传入参数转换拼接字符串
let postStr = getQueryString(params)
const signedStr = genSignStr(convertUrl, postStr)
const encryptStr = `sign=${signedStr}`
let encryptSignStr = fxCry.encryptByDES(encryptStr, config.secretKey)
encryptSignStr = encodeURIComponent(encryptSignStr)
return `${urlencode(convertUrl)}&_p=${encryptSignStr}`
}
}
function responseHandler(response: { data: any }) {
return response.data
}
// 响应拦截器
// Rq.interceptors.response.use(responseHandler)
const config = {
gameId: "100015",
secretKey: "HXKMEpdO",
EK:"hui231%1"
};
interface CrypotoType {
encryptByDES: any
decryptByDES: any
hmacSha256: any
}
class Crypoto implements CrypotoType {
// 加密的向明值,自己根据项目实际情况定,需要跟后端开发保持一致
private keyHex = this.getHetKey()
private getHetKey() {
return CryptoJS.enc.Utf8.parse(config.EK);
}
/** DES加密 */
encryptByDES(message: string, secret?: string) {
if(!message) {
return message
}
const key = secret? CryptoJS.enc.Utf8.parse(secret): this.keyHex
const encrypted = CryptoJS.DES.encrypt(message, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return encrypted.toString()
}
/** DES解密 */
decryptByDES(message: string, secret?: string) {
const key = secret? CryptoJS.enc.Utf8.parse(secret): this.keyHex
const decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(message)
}, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return decrypted.toString(CryptoJS.enc.Utf8)
}
/** hmacSHA256加密 */
hmacSha256(message: string, secret?: string) {
const keyHex = secret? CryptoJS.enc.Utf8.parse(secret): this.keyHex
const hash = CryptoJS.HmacSHA256(message, keyHex);
return hash.toString()
}
/** hmacSHA256验证 */
verifyHmacSha256(message: string, signature: string) {
const hash = CryptoJS.HmacSHA256(message, this.keyHex);
return hash.toString() === signature
}
/** CBC加密 */
encryptCBC(word: string) {
if (!word) {
return word;
}
const srcs = CryptoJS.enc.Utf8.parse(word);
const encrypted = CryptoJS.AES.encrypt(srcs, this.keyHex, {
iv: this.keyHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
});
return encrypted.toString();
}
/** CBC解密 */
decryptCBC(word: string) {
if (!word) {
return word;
}
const encryptedHexStr = CryptoJS.enc.Hex.parse(word);
const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
const decrypt = CryptoJS.AES.decrypt(srcs, this.keyHex, {
iv: this.keyHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
});
const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
}
}
const fxCry = new Crypoto();
function isEmpty(data) {
return data === "" || data === null || data === undefined || data.length === 0 || JSON.stringify(data) == "{}"
}
function getQueryString(obj) {
// 首先对对象的键进行排序并过滤空值
const sortedKeys = Object.keys(obj).sort();
const sortedObj = {};
for (let i = 0; i < sortedKeys.length; i++) {
if (isEmpty(obj[sortedKeys[i]])) {
continue;
}
sortedObj[sortedKeys[i]] = obj[sortedKeys[i]];
}
// 然后将排序后的对象转换为查询字符串
const params = [];
for (const key in sortedObj) {
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(sortedObj[key])}`);
}
return params.join('&');
}
/**
*
* @param string url: 请求地址
* @param string postStr: post参数的a=1&b=2
* @returns
*/
function genSignStr(url: string, postStr: string): string {
let lessUrl = url.replace('?', '')
lessUrl = lessUrl + "&" + postStr
return encodeURIComponent(fxCry.hmacSha256(lessUrl))
}
// 对参数进行统一urlencode
function urlencode(url: string): string {
const [baseUrl, queryString] = url.split("?", 2);
const params = new URLSearchParams(queryString);
return `${baseUrl}?${params.toString()}`;
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "771a3d9a-4013-4654-a777-fbaea0c93280",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "e64e1a97-c93f-4257-ab34-80341d8ff79d",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "b4e113c6-a987-4133-bfa0-3355d8ab4bd1",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,102 @@
import { GameConfig } from "../Config/GameConfig";
import HttpUtil from "../Crypto/HttpUtil";
import AudioManager from "../Music/AudioManager";
import { Notifications } from "../Notification/Notification";
import { StorageMessage } from "../Storage/Storage";
import { GameTool } from "../Tool/GameTool";
window.initMgr = function() {
if(cc.fx)
{
return;
}
cc.fx = {};
console.log("初始化");
//基础状态信息
cc.fx.StateInfo = {
debugMode: true,
networkConnected: true, //网络状态
networkType: 'none', //网络类型
isOnForeground: true //当前是否是在前台
};
//应用系统信息
//配置文件
cc.fx.GameConfig = GameConfig;
cc.fx.HttpUtil = HttpUtil;
cc.fx.GameTool = GameTool;
cc.fx.AudioManager = AudioManager;
cc.fx.Notifications = Notifications;
cc.fx.StorageMessage = StorageMessage;
cc.fx.ShareInfo = {
queryId : -1 //分享id
};
/*
*
*/
cc.fx.BurialShareType = {
Default : "default", //默认分享类型,分享到群
Invite : "invite", // 邀请好友
DailyInviteRoomJoin:'invite_join_room', //邀请好友加入
DailyInviteFriend : 'invite_friend', // 日常邀请好友
DailyInviteGroup : 'invate_group', // 日常分享群
DailyInviteGroupAlive: 'invate_alive', //日常分享群复活
DailyInviteGroupReward: 'invate_rewared',//分享奖励翻倍
DailyInviteGroupBox: 'invate_box', //宝箱分享奖励
DailyInviteGroupBall: 'invate_ball', //分享领取球球
MatchResult : 'matchResult', // 比赛结算分享
MatchFix5: 'MatchFix5', // 5元红包赛
MatchFix20: 'MatchFix20', // 20元红包赛
MatchFix100: 'MatchFix100', // 100元红包赛
MatchFix500: 'MatchFix500', // 500元红包赛
NewerRedEnvelope: 'newerRedEnvelope', // 新手红包
CoinRoomResult: 'coinRoomResult', // 金币桌结算
HighRate : "highRate",//高倍分享
CoinRoomWinStreak: 'coinRoomWinStreak', // 连胜
CoinRoomBankruptcy1: 'coinRoomBankruptcy1', // 金币桌破产
CoinRoomBankruptcy2: 'coinRoomBankruptcy2', // 金币桌破产
CoinRoomBankruptcy3: 'coinRoomBankruptcy3', // 金币桌破产
};
/*
* group frined all
*/
cc.fx.ShareWhereReward = {
Group :"group", //微信群
Friend : "friend",//好友
All : "all", //不区分
};
//暂时不用
cc.fx.clickStatEventType = {
clickStatEventTypeVideoAD : 20173201,//视频播放完成
clickStatEventTypeClickAdVideo : 20173202,//视频播放为完成
clickStatEventTypeBannerAD : 20173203,//banner播放为完成
clickStatEventTypeUserFrom : 99990001,//用户来源
clickStatEventTypeShare : 99990002,//用户分享
clickStatEventTypeClickAdBtn : 99990007,//点击分流icon
clickStatEventTypeBannerAD2 : 67890033, // banner广告干预
clickStatEventTypeSubmitVersionInfo : 9999, //上报微信版本及基础库信息
clickStatEventTypeClickFirstAd : 99990003, //分流icon显示
clickStatEventTypeClickSecondAd : 99990004, //玩家点击分流按钮
clickStatEventTypeWxLoginStart : 10001,//微信登录开始
clickStatEventTypeWxLoginSuccess : 10002,//微信登录成功
clickStatEventTypeWxLoginFailed : 10003,//微信登录失败
clickStatEventTypeAuthorizationStart : 10003,//授权开始
clickStatEventTypeAuthorizationSuccess : 10004,//授权成功
clickStatEventTypeAuthorizationFailed : 10005,//授权失败
clickStatEventTypeLoginSDKStart : 10007,//登录SDK开始
clickStatEventTypeLoginSDKSuccess : 10008,//登录SDK成功
clickStatEventTypeLoginSDKFailed : 10009,//登录SDK时失败
clickStatEventTypeTCP_Start : 10009,//TCP连接开始
clickStatEventTypeTCP_Success : 10010,//TCP连接成功
clickStatEventTypeTCP_Failed : 10011,//TCP连接失败
};
};

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "61d4c718-db3b-4b31-8221-f16bea3cf030",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "0487cacb-b94a-4ab6-a301-b6402ab0ac5d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,297 @@
const {ccclass, property} = cc._decorator;
@ccclass
export default class AudioManager extends cc.Component {
//背景音乐
@property(cc.AudioClip)
audioGameBgm0: cc.AudioClip = null;
//跳跃
@property(cc.AudioClip)
audioButtonClick: cc.AudioClip = null;
//落地上
@property(cc.AudioClip)
audioWarning: cc.AudioClip = null;
//碰撞
@property(cc.AudioClip)
audioWin: cc.AudioClip = null;
//落方块上
@property(cc.AudioClip)
luodui: cc.AudioClip = null;
mAudioMap: {};
bgMusicVolume: number;
effectMusicVolume: number;
mMusicSwitch: number;
mEffectSwitch: number;
brickSound: any;
reward: boolean;
finish: boolean;
rewardCount: number;
mMusicKey: any;
static _instance: any;
ctor () {
this.mAudioMap = {};
/**
*
* @type {number}
*/
this.bgMusicVolume = 0.1;
this.effectMusicVolume = 1;
this.mMusicSwitch = 1;
this.mEffectSwitch = 1;
}
play (audioSource, loop, callback, isBgMusic) {
if (isBgMusic && !this.mMusicSwitch) return;
if (!isBgMusic && !this.mEffectSwitch) return;
var volume = isBgMusic ? this.bgMusicVolume : this.effectMusicVolume;
if (cc.sys.isBrowser) {
if(audioSource == this.brickSound){
volume = 0.1;
}
volume = 1;
var context = cc.audioEngine.play(audioSource, loop, volume);
if (callback){
cc.audioEngine.setFinishCallback(context, function(){
callback.call(this);
}.bind(this));
}
// cc.wwx.OutPut.log('play audio effect isBrowser: ' + context.src);
this.mAudioMap[audioSource] = context;
return audioSource;
} else {
return audioSource;
}
}
save () {
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Music_Volume, this.mMusicSwitch);
// cc.wwx.Storage.setItem(cc.wwx.Storage.Key_Setting_Effect_Volume, this.mEffectSwitch);
}
onLoad() {
if (AudioManager._instance == null) {
AudioManager._instance = this;
cc.game.addPersistRootNode(this.node);
}
else {
this.node.destroy();
return;
}
this.reward = false;
this.finish = false;
this.rewardCount = 0;
this.ctor();
this.preload();
}
preload () {
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) { return; }
var musics = [
this.audioGameBgm0,
];
musics.forEach(function(path) {
// var musicPath = wxDownloader.REMOTE_SERVER_ROOT + path;
// if (musicPath != wxDownloader.REMOTE_SERVER_ROOT && musicPath.endsWith('.mp3')) {
// cc.loader.load(musicPath, function(err, remoteUrl) {
// if (err) {
// cc.error(err.message || err);
// return;
// }
// });
// }
})
}
getAudioMusicSwitch()
{
return this.mMusicSwitch;
}
getAudioEffectSwitch()
{
return this.mEffectSwitch;
}
trunAudioSound(on)
{
this.switchMusic(on);
this.switchEffect(on)
}
switchMusic (on) {
if (this.mMusicSwitch != (on?1:0))
{
this.mMusicSwitch = 1-this.mMusicSwitch;
// this.save();
}
if(on)
{
this.playMusicGame();
}
else
{
this.stopMusic();
}
}
switchEffect (on) {
if (this.mEffectSwitch != (on?1:0)){
this.mEffectSwitch = 1-this.mEffectSwitch;
// this.save();
}
}
onHide () {
cc.audioEngine.pauseAll();
// if (CC_JSB) {
// } else {
// for (var key in this.mAudioMap) {
// if (key === this.mMusicKey) {
// this.mAudioMap[key].pause();
// } else {
// this.mAudioMap[key].stop();
// }
// }
// }
}
onShow () {
cc.audioEngine.resumeAll();
// if (CC_JSB) {
// } else {
// if (!this.mMusicSwitch) return;
// var context = this.mAudioMap[this.mMusicKey];
// if (context) {
// context.play();
// }
// }
}
playMusic (key, callback, loop) {
loop = typeof loop == 'undefined' || loop ? true : false;
this.stopMusic();
this.mMusicKey = this.play(key, loop, callback, true);
}
/**
*
*/
playMusicGame () {
this.playMusic(this.audioGameBgm0,{},true);
}
/**
*
*/
stopMusic () {
// cc.wwx.OutPut.log('stopMusic audio effect wx: ' + this.mMusicKey);
var context = this.mAudioMap[this.mMusicKey];
if (typeof(context) != 'undefined') {
if (cc.sys.isBrowser) {
cc.audioEngine.stop(context);
} else {
context.stop();
}
cc.audioEngine.stop(context);
}
}
// 炸弹、火箭爆炸音效
playJump () {
}
//激光音效
playLuo()
{
return this.play(this.luodui, false,null,this.mEffectSwitch);
}
//技能音效
playGround()
{
}
//技能音效
playPz()
{
}
/*
*
*
*/
playGameStart()
{
}
/*
*
*/
playGameOver()
{
}
/*
*
*/
playGameResultFailed()
{
}
/*
*
*/
playGameResultSuccess()
{
}
/**
*
*/
playWarning()
{
return this.play(this.audioWarning, false,null,this.mEffectSwitch);
}
/*
*
*/
playBrick()
{
// return this.play(this.brickSound,false);
}
//方块破碎的声音
brickBoom(){
}
/**
*
*/
playAudioButton () {
return this.play(this.audioButtonClick, false,null,this.mEffectSwitch);
}
playWin()
{
return this.play(this.audioWin, false,null,this.mEffectSwitch);
}
playRandomMatch()
{
this.playMusic(this.audioGameBgm0,{},true);
}
playMatchFoundSound()
{
this.stopMusic();
// return this.play(this.matchFoundSound, false);
}
};
// export { AudioManager };

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "58403fe7-d7a2-426b-9b19-84d3236731a8",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "ff6560d9-676d-42ad-8ec7-e44acb84ad9e",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,45 @@
//全局通知
var Notifications = {
_eventMap: [],
on: function (masgId, callback, target) {
if (this._eventMap[masgId] === undefined) {
this._eventMap[masgId] = [];
}
this._eventMap[masgId].push({ callback: callback, target: target });
},
emit: function (masgId, parameter) {
let array = this._eventMap[masgId];
if (array === undefined) return;
for (let i = 0; i < array.length; i++) {
let element = array[i];
if (element) element.callback.call(element.target, parameter);
}
},
off: function (masgId, callback) {
let array = this._eventMap[masgId];
if (array === undefined) return;
for (let i = 0; i < array.length; i++) {
let element = array[i];
if (element && element.callback === callback) {
array[i] = undefined;
break;
}
}
},
offMasgId: function (masgId) {
this._eventMap[masgId] = undefined;
},
removeAllMsg: function () {
for (let k in this._eventMap) {
if (this._eventMap[k]) {
this.offMasgId(k);
}
}
}
};
export { Notifications };

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "55403563-1a5a-4f2f-9eb8-82c762641837",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "d3520299-33dc-43d2-b522-d424efb5575d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,74 @@
import List, { ListType } from "./List";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ItemRender extends cc.Component {
/**数据 */
public data:any = null;
/**索引 0表示第一项*/
public itemIndex:number = 0;
/**数据改变时调用 */
public dataChanged(){
let name = cc.fx.GameTool.subName(this.data.name,6);
this.node.getChildByName("rankLab").getComponent(cc.Label).string = this.data.rank + "";
this.node.getChildByName("nameLab").getComponent(cc.Label).string = name + "";
this.node.getChildByName("totalLab").getComponent(cc.Label).string = this.data.total + "";
this.node.getChildByName("rank").getChildByName("one").active = false;
this.node.getChildByName("rank").getChildByName("two").active = false;
this.node.getChildByName("rank").getChildByName("three").active = false;
if(this.data.rank == 1){
this.node.getChildByName("rank").getChildByName("one").active = true;
this.node.getChildByName("rankLab").active = false;
}
else if(this.data.rank == 2){
this.node.getChildByName("rank").getChildByName("two").active = true;
this.node.getChildByName("rankLab").active = false;
}
else if(this.data.rank == 3){
this.node.getChildByName("rank").getChildByName("three").active = true;
this.node.getChildByName("rankLab").active = false;
}else{
this.node.getChildByName("rankLab").active = true;
}
this.setPic();
}
public setPic(){
this.node.getChildByName("pic").getChildByName("icon").active = false;
this.node.getChildByName("pic").getChildByName("pic").active= false;
var self = this;
let url = this.data.pic;
fetch(url)
.then(response => {
return response.headers.get('Content-Length');
})
.then(errNo => {
// console.log(this.data.rank,'X-Info:', errNo); // 输出X-ErrNo的值
if(errNo == "5093"){
// console.log(this.data.rank,"没头像");
this.node.getChildByName("pic").getChildByName("icon").active = true;
}
})
.catch(error => {
// console.error('Error fetching X-Info:', error);
});
cc.assetManager.loadRemote(url,{ext:'.png'},(err, texture:cc.Texture2D) => {
if(texture){
this.node.getChildByName("pic").getChildByName("pic").active= true;
var sprite = this.node.getChildByName("pic").getChildByName("pic").getComponent(cc.Sprite);
sprite.spriteFrame = new cc.SpriteFrame(texture);
// console.log(this.data.rank,"设置头像成功",err);
}
else{
// console.log("设置头像失败",url);
console.log(err,texture)
}
})
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "ca0f9934-a015-436e-9402-f8e30d4c5de6",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,592 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import ItemRender from "./ItemRender"
const { ccclass, property } = cc._decorator;
/**列表排列方式 */
export enum ListType {
/**水平排列 */
Horizontal = 1,
/**垂直排列 */
Vertical = 2,
/**网格排列 */
Grid = 3
}
/**网格布局中的方向 */
export enum StartAxisType {
/**水平排列 */
Horizontal = 1,
/**垂直排列 */
Vertical = 2,
}
/**
*
* cocos_example的listView改动而来
* @author chenkai 2020.7.8
* @example
* 1.cocos的ScrollView组件ListList属性即可
*
*/
@ccclass
export default class List extends cc.Component {
//==================== 属性面板 =========================
/**列表选项 */
@property({ type: cc.Node, tooltip: "列表项" })
public itemRender: cc.Node = null;
/**排列方式 */
@property({ type: cc.Enum(ListType), tooltip: "排列方式" })
public type: ListType = ListType.Vertical;
/**网格布局中的方向 */
@property({ type: cc.Enum(StartAxisType), tooltip: "网格布局中的方向", visible() { return this.type == ListType.Grid } })
public startAxis: StartAxisType = StartAxisType.Horizontal;
/**列表项之间X间隔 */
@property({ type: cc.Integer, tooltip: "列表项X间隔", visible() { return (this.type == ListType.Horizontal || this.type == ListType.Grid) } })
public spaceX: number = 0;
/**列表项之间Y间隔 */
@property({ type: cc.Integer, tooltip: "列表项Y间隔", visible() { return this.type == ListType.Vertical || this.type == ListType.Grid } })
public spaceY: number = 0;
/**上间距 */
@property({ type: cc.Integer, tooltip: "上间距", visible() { return (this.type == ListType.Vertical || this.type == ListType.Grid) } })
public padding_top: number = 0;
/**下间距 */
@property({ type: cc.Integer, tooltip: "下间距", visible() { return (this.type == ListType.Vertical || this.type == ListType.Grid) } })
public padding_buttom: number = 0;
/**左间距 */
@property({ type: cc.Integer, tooltip: "左间距", visible() { return (this.type == ListType.Horizontal || this.type == ListType.Grid) } })
public padding_left: number = 0;
@property(cc.Integer)
public _padding: number = 0;
/**右间距 */
@property({ type: cc.Integer, tooltip: "右间距", visible() { return (this.type == ListType.Horizontal || this.type == ListType.Grid) } })
public padding_right: number = 0;
//====================== 滚动容器 ===============================
/**列表滚动容器 */
public scrollView: cc.ScrollView = null;
/**scrollView的内容容器 */
private content: cc.Node = null;
//======================== 列表项 ===========================
/**列表项数据 */
private itemDataList: Array<any> = [];
/**应创建的实例数量 */
private spawnCount: number = 0;
/**存放列表项实例的数组 */
private itemList: Array<cc.Node> = [];
/**item的高度 */
private itemHeight: number = 0;
/**item的宽度 */
private itemWidth: number = 0;
/**存放不再使用中的列表项 */
private itemPool: Array<cc.Node> = [];
//======================= 计算参数 ==========================
/**距离scrollView中心点的距离超过这个距离的item会被重置一般设置为 scrollVIew.height/2 + item.heigt/2 + space因为这个距离item正好超出scrollView显示范围 */
private halfScrollView: number = 0;
/**上一次content的X值用于和现在content的X值比较得出是向左还是向右滚动 */
private lastContentPosX: number = 0;
/**上一次content的Y值用于和现在content的Y值比较得出是向上还是向下滚动 */
private lastContentPosY: number = 0;
/**网格行数 */
private gridRow: number = 0;
/**网格列数 */
private gridCol: number = 0;
/**刷新时间单位s */
private updateTimer: number = 0;
/**刷新间隔单位s */
private updateInterval: number = 0.1;
/**是否滚动容器 */
private bScrolling: boolean = false;
/**刷新的函数 */
private updateFun: Function = function () { };
onLoad() {
this.itemHeight = this.itemRender.height;
this.itemWidth = this.itemRender.width;
this.scrollView = this.node.getComponent(cc.ScrollView);
this.content = this.scrollView.content;
this.content.anchorX = 0;
this.content.anchorY = 1;
this.content.removeAllChildren();
this.scrollView.node.on("scrolling", this.onScrolling, this);
}
/**
* (使)
* @param itemDataList item数据列表
*/
public setData(itemDataList: Array<any>) {
this.itemDataList = itemDataList.slice();
this.updateContent();
}
/**计算列表的各项参数 */
private countListParam() {
let dataLen = this.itemDataList.length;
if (this.type == ListType.Vertical) {
this.scrollView.horizontal = false;
this.scrollView.vertical = true;
this.content.width = this.content.parent.width;
this.content.height = dataLen * this.itemHeight + (dataLen - 1) * this.spaceY + this.padding_top + this.padding_buttom;
this.spawnCount = Math.round(this.scrollView.node.height / (this.itemHeight + this.spaceY)) + 2; //计算创建的item实例数量比当前scrollView容器能放下的item数量再加上2个
this.halfScrollView = this.scrollView.node.height / 2 + this.itemHeight / 2 + this.spaceY; //计算bufferZoneitem的显示范围
this.updateFun = this.updateV;
} else if (this.type == ListType.Horizontal) {
this.scrollView.horizontal = true;
this.scrollView.vertical = false;
this.content.width = dataLen * this.itemWidth + (dataLen - 1) * this.spaceX + this.padding_left + this.padding_right;
this.content.height = this.content.parent.height;
this.spawnCount = Math.round(this.scrollView.node.width / (this.itemWidth + this.spaceX)) + 2;
this.halfScrollView = this.scrollView.node.width / 2 + this.itemWidth / 2 + this.spaceX;
this.updateFun = this.udpateH;
} else if (this.type == ListType.Grid) {
if (this.startAxis == StartAxisType.Vertical) {
this.scrollView.horizontal = false;
this.scrollView.vertical = true;
this.content.width = this.content.parent.width;
//如果left和right间隔过大导致放不下一个item则left和right都设置为0相当于不生效
if (this.padding_left + this.padding_right + this.itemWidth + this.spaceX > this.content.width) {
this.padding_left = 0;
this.padding_right = 0;
console.error("padding_left或padding_right过大");
}
this.gridCol = Math.floor((this.content.width - this.padding_left - this.padding_right) / (this.itemWidth + this.spaceX));
this.gridRow = Math.ceil(dataLen / this.gridCol);
this.content.height = this.gridRow * this.itemHeight + (this.gridRow - 1) * this.spaceY + this.padding_top + this.padding_buttom;
this.spawnCount = Math.round(this.scrollView.node.height / (this.itemHeight + this.spaceY)) * this.gridCol + this.gridCol * 2;
this.halfScrollView = this.scrollView.node.height / 2 + this.itemHeight / 2 + this.spaceY;
this.updateFun = this.updateGrid_V;
} else if (this.startAxis == StartAxisType.Horizontal) {
this.scrollView.horizontal = true;
this.scrollView.vertical = false;
//计算高间隔
this.content.height = this.content.parent.height;
//如果left和right间隔过大导致放不下一个item则left和right都设置为0相当于不生效
if (this.padding_top + this.padding_buttom + this.itemHeight + this.spaceY > this.content.height) {
this.padding_top = 0;
this.padding_buttom = 0;
console.error("padding_top或padding_buttom过大");
}
this.gridRow = Math.floor((this.content.height - this.padding_top - this.padding_buttom) / (this.itemHeight + this.spaceY));
this.gridCol = Math.ceil(dataLen / this.gridRow);
this.content.width = this.gridCol * this.itemWidth + (this.gridCol - 1) * this.spaceX + this.padding_left + this.padding_right;
this.spawnCount = Math.round(this.scrollView.node.width / (this.itemWidth + this.spaceX)) * this.gridRow + this.gridRow * 2;
this.halfScrollView = this.scrollView.node.width / 2 + this.itemWidth / 2 + this.spaceX;
this.updateFun = this.updateGrid_H;
}
}
}
/**
*
* @param startIndex 0
* @param offset scrollView偏移量
*/
private createList(startIndex: number, offset: cc.Vec2) {
//当需要显示的数据长度 > 虚拟列表长度, 删除最末尾几个数据时列表需要重置位置到scrollView最底端
if (this.itemDataList.length > this.spawnCount && (startIndex + this.spawnCount - 1) >= this.itemDataList.length) {
startIndex = this.itemDataList.length - this.spawnCount;
offset = this.scrollView.getMaxScrollOffset();
//当需要显示的数据长度 <= 虚拟列表长度, 隐藏多余的虚拟列表项
} else if (this.itemDataList.length <= this.spawnCount) {
startIndex = 0;
}
for (let i = 0; i < this.spawnCount; i++) {
let item: cc.Node;
//需要显示的数据索引在数据范围内则item实例显示出来
if (i + startIndex < this.itemDataList.length) {
if (this.itemList[i] == null) {
item = this.getItem();
this.itemList.push(item);
item.parent = this.content;
} else {
item = this.itemList[i];
}
//需要显示的数据索引超过了数据范围则item实例隐藏起来
} else {
//item实例数量 > 需要显示的数据量
if (this.itemList.length > (this.itemDataList.length - startIndex)) {
item = this.itemList.pop();
item.removeFromParent();
this.itemPool.push(item);
}
continue;
}
let itemRender: ItemRender = item.getComponent(ItemRender);
itemRender.itemIndex = i + startIndex;
itemRender.data = this.itemDataList[i + startIndex];
itemRender.dataChanged();
if (this.type == ListType.Vertical) {
//因为content的锚点X是0所以item的x值是content.with/2表示居中锚点Y是1所以item的y值从content顶部向下是0到负无穷。所以item.y= -item.height/2时是在content的顶部。
item.setPosition(this.content.width / 2, -item.height * (0.5 + i + startIndex) - this.spaceY * (i + startIndex) - this.padding_top);
} else if (this.type == ListType.Horizontal) {
item.setPosition(item.width * (0.5 + i + startIndex) + this.spaceX * (i + startIndex) + this.padding_left, -this.content.height / 2);
} else if (this.type == ListType.Grid) {
if (this.startAxis == StartAxisType.Vertical) {
var row = Math.floor((i + startIndex) / this.gridCol);
var col = (i + startIndex) % this.gridCol;
item.setPosition(item.width * (0.5 + col) + this.spaceX * col + this.padding_left, -item.height * (0.5 + row) - this.spaceY * row - this.padding_top);
item.opacity = 255;
} else if (this.startAxis == StartAxisType.Horizontal) {
var row = (i + startIndex) % this.gridRow;
var col = Math.floor((i + startIndex) / this.gridRow);
item.setPosition(item.width * (0.5 + col) + this.spaceX * col + this.padding_left, -item.height * (0.5 + row) - this.spaceY * row - this.padding_top);
item.opacity = 255;
}
}
}
this.scrollView.scrollToOffset(offset);
}
/**获取一个列表项 */
private getItem() {
if (this.itemPool.length == 0) {
return cc.instantiate(this.itemRender);
} else {
return this.itemPool.pop();
}
}
update(dt) {
if (this.bScrolling == false) {
return;
}
this.updateTimer += dt;
if (this.updateTimer < this.updateInterval) {
return;
}
this.updateTimer = 0;
this.bScrolling = false;
this.updateFun();
}
onScrolling() {
this.bScrolling = true;
}
/**垂直排列 */
private updateV() {
let items = this.itemList;
let item;
let bufferZone = this.halfScrollView;
let isUp = this.scrollView.content.y > this.lastContentPosY;
let offset = (this.itemHeight + this.spaceY) * items.length;
for (let i = 0; i < items.length; i++) {
item = items[i];
let viewPos = this.getPositionInView(item);
if (isUp) {
//item上滑时超出了scrollView上边界将item移动到下方复用item移动到下方的位置必须不超过content的下边界
if (viewPos.y > bufferZone && item.y - offset - this.padding_buttom > -this.content.height) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex + items.length;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.y = item.y - offset;
}
} else {
//item下滑时超出了scrollView下边界将item移动到上方复用item移动到上方的位置必须不超过content的上边界
if (viewPos.y < -bufferZone && item.y + offset + this.padding_top < 0) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex - items.length;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.y = item.y + offset;
}
}
}
this.lastContentPosY = this.scrollView.content.y;
}
/**水平排列 */
private udpateH() {
let items = this.itemList;
let item;
let bufferZone = this.halfScrollView;
let isRight = this.scrollView.content.x > this.lastContentPosX;
let offset = (this.itemWidth + this.spaceX) * items.length;
for (let i = 0; i < items.length; i++) {
item = items[i];
let viewPos = this.getPositionInView(item);
if (isRight) {
//item右滑时超出了scrollView右边界将item移动到左方复用item移动到左方的位置必须不超过content的左边界
if (viewPos.x > bufferZone && item.x - offset - this.padding_left > 0) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex - items.length;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.x = item.x - offset;
}
} else {
//item左滑时超出了scrollView左边界将item移动到右方复用item移动到右方的位置必须不超过content的右边界
if (viewPos.x < -bufferZone && item.x + offset + this.padding_right < this.content.width) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex + items.length;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.x = item.x + offset;
}
}
}
this.lastContentPosX = this.scrollView.content.x;
}
/**网格垂直排列 */
private updateGrid_V() {
let items = this.itemList;
let item: cc.Node;
let bufferZone = this.halfScrollView;
let isUp = this.scrollView.content.y > this.lastContentPosY;
let offset = (this.itemHeight + this.spaceY) * (this.spawnCount / this.gridCol);
for (let i = 0; i < items.length; i++) {
item = items[i];
let viewPos = this.getPositionInView(item);
if (isUp) {
//item上滑时超出了scrollView上边界将item移动到下方复用item移动到下方的位置必须不超过content的下边界
if (viewPos.y > bufferZone && item.y - offset - this.padding_buttom > -this.content.height) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex + (this.spawnCount / this.gridCol) * this.gridCol;
if (this.itemDataList[itemIndex] != null) {
item.y = item.y - offset;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.opacity = 255;
} else {
item.y = item.y - offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
}
}
} else {//item下滑时超出了scrollView下边界将item移动到上方复用item移动到上方的位置必须不超过content的上边界
if (viewPos.y < -bufferZone && item.y + offset + this.padding_top < 0) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex - (this.spawnCount / this.gridCol) * this.gridCol;
if (this.itemDataList[itemIndex] != null) {
item.y = item.y + offset;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.opacity = 255;
} else {
item.y = item.y + offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
}
}
}
}
this.lastContentPosY = this.scrollView.content.y;
}
/**网格水平排列 */
private updateGrid_H() {
let items = this.itemList;
let item;
let bufferZone = this.halfScrollView;
let isRight = this.scrollView.content.x > this.lastContentPosX;
let offset = (this.itemWidth + this.spaceX) * (this.spawnCount / this.gridRow);
for (let i = 0; i < items.length; i++) {
item = items[i];
let viewPos = this.getPositionInView(item);
if (isRight) {
//item右滑时超出了scrollView右边界将item移动到左方复用item移动到左方的位置必须不超过content的左边界
if (viewPos.x > bufferZone && item.x - offset - this.padding_left > 0) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex - (this.spawnCount / this.gridRow) * this.gridRow;
if (this.itemDataList[itemIndex] != null) {
item.x = item.x - offset;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.opacity = 255;
} else {
item.x = item.x - offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
}
}
} else {
//item左滑时超出了scrollView左边界将item移动到右方复用item移动到右方的位置必须不超过content的右边界
if (viewPos.x < -bufferZone && item.x + offset + this.padding_right < this.content.width) {
let itemRender: ItemRender = item.getComponent(ItemRender);
let itemIndex = itemRender.itemIndex + (this.spawnCount / this.gridRow) * this.gridRow;
if (this.itemDataList[itemIndex] != null) {
item.x = item.x + offset;
itemRender.itemIndex = itemIndex;
itemRender.data = this.itemDataList[itemIndex];
itemRender.dataChanged();
item.opacity = 255;
} else {
item.x = item.x + offset;
itemRender.itemIndex = itemIndex;
item.opacity = 0;
}
}
}
}
this.lastContentPosX = this.scrollView.content.x;
}
/**获取item在scrollView的局部坐标 */
private getPositionInView(item) {
let worldPos = item.parent.convertToWorldSpaceAR(item.position);
let viewPos = this.scrollView.node.convertToNodeSpaceAR(worldPos);
return viewPos;
}
/**获取列表数据 */
public getListData() {
return this.itemDataList;
}
/**
*
* @param data
*/
public addItem(data: any) {
this.itemDataList.push(data);
this.updateContent();
}
/**
*
* @param index 01
* @param data
*/
public addItemAt(index: number, data: any) {
if (this.itemDataList[index] != null || this.itemDataList.length == index) {
this.itemDataList.splice(index, 1, data);
this.updateContent();
}
}
/**
*
* @param index ,01
*/
public deleteItem(index: number) {
if (this.itemDataList[index] != null) {
this.itemDataList.splice(index, 1);
this.updateContent();
}
}
/**
*
* @param index ,01
* @param data
*/
public changeItem(index: number, data: any) {
if (this.itemDataList[index] != null) {
this.itemDataList[index] = data;
this.updateContent();
}
}
/**获取第一个Item的位置 */
private updateContent() {
//显示列表实例为0个
if (this.itemList.length == 0) {
this.countListParam();
this.createList(0, new cc.Vec2(0, 0));
//显示列表的实例不为0个则需要重新排列item实例数组
} else {
if (this.type == ListType.Vertical) {
this.itemList.sort((a: any, b: any) => {
return b.y - a.y;
});
} else if (this.type == ListType.Horizontal) {
this.itemList.sort((a: any, b: any) => {
return a.x - b.x;
});
} else if (this.type == ListType.Grid) {
if (this.startAxis == StartAxisType.Vertical) {
this.itemList.sort((a: any, b: any) => {
return a.x - b.x;
});
this.itemList.sort((a: any, b: any) => {
return b.y - a.y;
});
} else if (this.startAxis == StartAxisType.Horizontal) {
this.itemList.sort((a: any, b: any) => {
return b.y - a.y;
});
this.itemList.sort((a: any, b: any) => {
return a.x - b.x;
});
}
}
this.countListParam();
//获取第一个item实例需要显示的数据索引
var startIndex = this.itemList[0].getComponent(ItemRender).itemIndex;
if (this.type == ListType.Grid && this.startAxis == StartAxisType.Vertical) {
startIndex += (startIndex + this.spawnCount) % this.gridCol;
} else if (this.type == ListType.Grid && this.startAxis == StartAxisType.Horizontal) {
startIndex += (startIndex + this.spawnCount) % this.gridRow;
}
//getScrollOffset()和scrollToOffset()的x值是相反的
var offset: cc.Vec2 = this.scrollView.getScrollOffset();
offset.x = - offset.x;
this.createList(startIndex, offset);
}
}
/**销毁 */
public onDestroy() {
//清理列表项
let len = this.itemList.length;
for (let i = 0; i < len; i++) {
if (cc.isValid(this.itemList[i], true)) {
this.itemList[i].destroy();
}
}
this.itemList.length = 0;
//清理对象池
len = this.itemPool.length;
for (let i = 0; i < len; i++) {
if (cc.isValid(this.itemPool[i], true)) {
this.itemPool[i].destroy();
}
}
this.itemPool.length = 0;
//清理列表数据
this.itemDataList.length = 0;
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "d54211e0-2d28-4528-88e3-e5fd7c9b59a2",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "765cf1ea-e992-4789-a609-fbf772888afa",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,103 @@
var shareConfig = {
gameId: "100015",
shareLine: "zDLsruVI",
EK:"hui231%1"
};
// 定义微信配置数据的接口
interface IWeChatConfig {
appId: string;
timestamp: number;
nonceStr: string;
signature: string;
jsApiList: [];
}
// 微信操作类
export class WeChat {
static setShare(url) {
var urlTemp = this.removeQueryParams(url);
shareConfig.shareLine = urlTemp;
WeChat.getSignature(url);
}
static getResult(res){
if(res){
var data = res.data;
// @ts-ignore
wx.config({
debug: false,
appId: data.appId,
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: ['onMenuShareTimeline','updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage']
});
// @ts-ignore
wx.checkJsApi({
jsApiList: ['updateAppMessageShareData'], // 需要检测的JS接口列表所有JS接口列表见附录2,
success: function(res) {
setTimeout(() => {
WeChat.changeShare();
}, 200);
setTimeout(() => {
WeChat.changeShare();
}, 500);
}
});
}
}
static changeShare(){
// @ts-ignore
wx.ready(() => {
// @ts-ignore
wx.updateAppMessageShareData({
title: '记忆力认知测评', // 分享标题
desc: '你的注意力和工作记忆有问题吗?', // 分享描述
link: shareConfig.shareLine, // 分享链接该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: 'https://static.sparkus.cn/public/shootsun.jpg', // 分享图标
success: function () {
// 设置成功
console.log("分享好友成功回调");
}
});
setTimeout(() => {
// @ts-ignore
wx.updateTimelineShareData({
title: '记忆力认知测评', // 分享标题
link: shareConfig.shareLine, // 分享链接该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: 'https://static.sparkus.cn/public/shootsun.jpg', // 分享图标
success: function () {
// 设置成功
console.log("分享朋友圈成功回调");
}
})
}, 200);
});
}
static getSignature(url: string): Promise<IWeChatConfig> {
return new Promise((resolve) => {
WeChat.getShareInfo((encodeURIComponent(url)),WeChat.getResult);
});
}
static async getShareInfo(shareUrl: string, callback:Function): Promise<any> {
const time = Math.floor((new Date().getTime()) / 1000)
const url = cc.fx.HttpUtil.apiSign(`/api/share/cfg?gameId=${cc.fx.GameConfig.GM_INFO.gameId}&time=${time}&url=${shareUrl}`,{})
return cc.fx.HttpUtil.get(url,callback,3)
}
static containsNanana(str) {
return /test/i.test(str);
}
static removeQueryParams(url) {
return url.replace(/\?.*$/, '');
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "7290c680-dfdc-4c59-9736-a614cc2a8bcf",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "2af8f2ef-b8a0-43ad-a144-ef4a887f2fa9",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,27 @@
//缓存浏览器数据
var StorageMessage = {
getStorage : function(key){
var result = null;
if(cc.sys.localStorage.getItem(key)){
var result = cc.sys.localStorage.getItem(key);
}
if(result){
result = JSON.parse(result);
}
return result;
},
setStorage : function(key,value){
//主动拉起分享接口
var temp = JSON.stringify(value);
cc.sys.localStorage.setItem(key, temp)
},
removeStorage : function(key){
//主动删除消息接口
if(cc.sys.localStorage.getItem(key)){
cc.sys.localStorage.removeItem(key)
}
},
};
export { StorageMessage };

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "10029dfc-5454-4977-bd11-8809e8f48cac",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "2a81f82d-8d16-44af-b947-44eea4dde54f",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,272 @@
//最大工具类 各种公共方法,以及处理上传,获取后端接口数据
var GameTool = {
_startTime: 0,
_endTime: 0,
_totalTime: 0,
//获取userId
Authentication(){
let name = "user_" + cc.fx.GameConfig.GM_INFO.gameId;
var data = null;
if(localStorage.getItem(name)) data = JSON.parse(localStorage.getItem(name));
if(data == "undifend" || data==null || data == ""){
let url = "https://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback="+
encodeURIComponent(location.href);
console.log("链接没ID准备跳转",url);
window.location.href = url;
}
else{
if(!this.isNumber(data.userId)){
let url = "https://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback="+
encodeURIComponent(location.href);
console.log("链接不合法",url);
window.location.href = url;
}
else{
cc.fx.StorageMessage.setStorage(name,data);
cc.fx.GameConfig.GM_INFO.userId = parseInt(data.userId);
}
}
},
isNumber(value) {
var result = false;
result = typeof value === 'number';
if(result) if(value < 200000) result = false;
return result;
},
//埋点上传
setGameData(){
//GAME_DATA 初始化 每次清零
cc.fx.GameConfig.GAME_DATA = [];
cc.fx.GameConfig.GAME_DATA.push(cc.fx.GameConfig.CLICK_DATA);
let level = cc.fx.GameConfig.CLICK_DATA.round;
cc.fx.GameConfig.CLICK_init();
let data = cc.fx.GameConfig.GAME_DATA;
let matchId = this.getMatchId(level);
let postData = {
"gameId":cc.fx.GameConfig.GM_INFO.gameId,
"userId":cc.fx.GameConfig.GM_INFO.userId,
"scode":cc.fx.GameConfig.GM_INFO.scode,
"matchId":matchId,
"data": data
};
console.log("上传数据:",postData);
cc.fx.HttpUtil.uploadUserLogData(postData,function(){})
},
//上传排行榜 type为1
setRank(data){
//GAME_DATA 初始化 每次清零
let postData = {
"gameId":cc.fx.GameConfig.GM_INFO.gameId,
"userId":cc.fx.GameConfig.GM_INFO.userId,
"type":1,
"reactionTime": data,
"totalSunCount": cc.fx.GameConfig.GM_INFO.total,
"success": cc.fx.GameConfig.GM_INFO.success
};
cc.fx.HttpUtil.rankData(1,function(){},postData);
},
//获取排行榜 type为2
getRank(data,callback){
let rankLength = data.length;
let postData = {
"gameId":cc.fx.GameConfig.GM_INFO.gameId,
"userId":cc.fx.GameConfig.GM_INFO.userId,
"page":1,
"pageSize":rankLength
};
//回调进getRankData
cc.fx.HttpUtil.rankData(2,data =>{callback(data)},postData);
},
//获取matchId 用于上传每次点击数据里面记录id方便查询
getMatchId (level){
let matchId = cc.sys.localStorage.getItem("matchId");
let tempId = matchId;
if(matchId == "undifend" || matchId==null){
matchId = this.setMatchId();
}
else{
if(this.containsNanana(matchId) == true){
matchId = this.setMatchId();
}
else{
let char = parseInt(tempId.substring(10,tempId.length));
if(level == 1){
char += 1;
matchId = tempId.slice(0, 10) + char + "";
if(this.containsNanana(matchId)) matchId = this.setMatchId();
cc.fx.GameConfig.GM_INFO.matchId = matchId;
cc.sys.localStorage.setItem("matchId",matchId);
}
}
}
if(this.containsNanana(matchId) == true){
matchId = this.setMatchId();
}
return matchId;
},
//检测matchId 如果有缓存以前的nanana数据清除
containsNanana(str) {
return /na/i.test(str);
},
//重新设置MatchId
setMatchId (){
// 定义包含可用字符的字符集
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
// 创建一个数组以保存随机字符
const uuidArray = [];
// 循环10次 生成10位的UUID
for (let i = 0; i < 10; i++) {
// 生成随机索引,范围是字符集的长度
const randomIndex = Math.floor(Math.random() * characters.length);
// 从字符集中获取随机字符
const randomChar = characters.charAt(randomIndex);
// 将字符添加到数组中
uuidArray.push(randomChar);
}
let data = uuidArray.join('') + 1 + "";
cc.sys.localStorage.setItem("matchNumber",1);
if(this.containsNanana(data)) data = this.setMatchId();
cc.sys.localStorage.setItem("matchId",data);
cc.fx.GameConfig.GM_INFO.matchId = data;
return data;
},
//截取名字
subName(name,length){
if(name.length > length){
name = name.substring(0,length) + "..."
}
return name;
},
//设置头像
setPic(node,pic){
node.active = false;
let url = pic;
setTimeout(() => {
fetch(url)
.then(response => {
return response.headers.get('Content-Length');
})
.then(errNo => {
if(errNo == "5093"){
node.active = true;
}
})
.catch(error => {
// console.error('Error fetching X-Info:', error);
});
}, 100);
cc.assetManager.loadRemote(url , {ext:'.png'},(err, texture:cc.Texture2D) => {
if(texture){
node.active = true;
node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
}
else{
// console.log(err,texture)
}
})
},
//第一个参数把目标带进来处理,第二个参数为名字长度,不同场景不同需求
//名字4短小排行名字6长大排行
getRankData(data,target,nameLength){
target.listData = data.data.list;
target.selfData = data.data.info;
let rankData = [];
let self = false;
cc.fx.GameTool.setPic(target.selfNode.getChildByName("pic").getChildByName("icon"),target.selfData.pic);
for(let i=0;i<=target.listData.length-1;i++){
rankData.push({rank:(i+1), name:target.listData[i].nickName, total:target.listData[i].totalSunCount, pic:target.listData[i].pic});
if(cc.fx.GameConfig.GM_INFO.userId == target.listData[i].userId){
self = true;
target.rankNumber = i;
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string =(i+1) + "";
}
if(i == (target.listData.length-1) && self == false){
target.rankNumber = i;
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = "99+";
}
}
let name = cc.fx.GameTool.subName(target.selfData.nickName,nameLength);
target.selfNode.getChildByName("nameLab").getComponent(cc.Label).string = name;
target.selfNode.getChildByName("totalLab").getComponent(cc.Label).string = target.selfData.totalSunCount;
switch(target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string){
case "1":
target.selfNode.getChildByName("rank").getChildByName("one").active = true;
break;
case "2":
target.selfNode.getChildByName("rank").getChildByName("two").active = true;
break;
case "3":
target.selfNode.getChildByName("rank").getChildByName("three").active = true;
break;
}
// 大排行
if(nameLength == 6){
target.rankList.setData(rankData);
target.selfNode.opacity = 255;
if(target.selfData.totalSunCount == 0) target.selfNode.opacity = 0;
}
},
getSetScreenResolutionFlag: function () {
let size = cc.winSize;
let width = size.width;
let height = size.height;
if ((height / width) > (16.2 / 9)) return false;
return true;
},
//判断全面屏适配
setFit: function (canvas) {
let flag = cc.fx.GameTool.getSetScreenResolutionFlag();
if (flag) {
// console.log("不是全面屏");
} else {
// console.log("是全面屏");
}
return flag;
},
//获取游戏信息
getGameInfo: function(node){
var jg = false;
return jg;
},
//设置游戏信息
setGameInfo: function(pd){
},
//输入秒,返回需要展示时间格式
getTimeMargin:(second) => {
let total = 0;
total = second;
let hour = 0;
hour = parseInt((total / 3600) + "");//计算整数小时数
let afterHour = total - hour * 60 * 60;//取得算出小时数后剩余的秒数
let min = parseInt((afterHour / 60)+"");//计算整数分
let m = "" + min;
if(min < 10) m = "0"+min;
let afterMin = total - hour * 60 * 60 - min * 60;//取得算出分后剩余的秒数
let miao = afterMin + "";
if(afterMin < 10) miao = "0" + afterMin;
return m + ':' + miao
},
//获取时间戳
getTime(){
const timestamp = new Date().getTime();
return timestamp;
},
pushLister:function () {
},
removeAllLister:function () {
},
};
export { GameTool };

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "43bfc27a-ff6e-45b3-87c7-504d0f781397",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/Shader.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "afa9e39a-94ca-477f-8a2a-25082d9092c3",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "d480c86c-c0a4-49ba-8b45-5f00deb51178",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 128,
"height": 128,
"platformSettings": {},
"subMetas": {
"Effect_fluid": {
"ver": "1.0.6",
"uuid": "38b9017e-ef9d-4890-a459-350f3be901a4",
"importer": "sprite-frame",
"rawTextureUuid": "d480c86c-c0a4-49ba-8b45-5f00deb51178",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": 0,
"trimX": 5,
"trimY": 0,
"width": 117,
"height": 128,
"rawWidth": 128,
"rawHeight": 128,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "afa85bd2-7b47-4171-b74f-2e72c7cbb9ff",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 100,
"height": 128,
"platformSettings": {},
"subMetas": {
"Effect_fluid2": {
"ver": "1.0.6",
"uuid": "5726e9d2-3cc2-489c-a93e-2ca52201e653",
"importer": "sprite-frame",
"rawTextureUuid": "afa85bd2-7b47-4171-b74f-2e72c7cbb9ff",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 100,
"height": 128,
"rawWidth": 100,
"rawHeight": 128,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

View File

@ -0,0 +1,148 @@
//扫光-纹理
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_fluxayTexture: { value: white }
u_time: { value: 0 }
u_scale: { value: 1.0 }
u_angle: { value: 30.0 }
}%
// Vertex Shader(顶点着色器)
// 将顶点从模型空间坐标系统转化到屏幕空间坐标系统
// 顶点着色器分为输入和输出两部分
// 负责的功能是把输入的数据进行矩阵变换位置,计算光照公式生成逐顶点颜⾊,⽣成/变换纹理坐标
// 并且把位置和纹理坐标这样的参数发送到片段着色器
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
// 输入的纹理坐标
// UV坐标原点在左上角u轴是向右v轴是向下范围是0-1
in vec2 a_uv0;
// 输出的纹理坐标
out vec2 v_uv0;
#endif
void main () {
mat4 mvp;
#if CC_USE_MODEL
mvp = cc_matViewProj * cc_matWorld;
#else
mvp = cc_matViewProj;
#endif
v_uv0 = a_uv0;
v_color = a_color;
gl_Position = mvp * vec4(a_position, 1);
}
}%
// Fragment Shader(片段着色器)
// 片元着色器的作用是处理由光栅化阶段生成的每个片元,最终计算出每个像素的最终颜色(RGBA)
CCProgram fs %{
precision highp float;
#include <alpha-test>
#include <texture>
in vec4 v_color;
in vec2 v_uv0;
uniform sampler2D texture;
uniform sampler2D u_fluxayTexture; //流光纹理
// 自定义属性
// 所有非 sampler 的 uniform 都必须以 UBO 形式声明
// UBO 成员声明类型和顺序有严格的校验机制,以排除 GL 标准下隐式布局对齐带来的内存消耗
uniform ARGS {
float u_time;
float u_scale;
float u_angle;
};
vec2 transformUV(vec2 UV,float angle){
float rotate = (angle * 3.1415926) / 180.0;
vec2 di = vec2(0.5, 0.5); // 旋转的中心位置
//float a = cos(rotate);
mat3 m = mat3(cos(rotate), -sin(rotate), 0.0,sin(rotate), cos(rotate), 0.0,0.0, 0.0, 1.0);
//vec3 uv = vec3(UV.x-di.x,UV.y+di.y, 1.0)* m;
//return vec2(uv.x,uv.y)+vec2(di.x,-di.y);
vec3 uv = vec3(UV.x,UV.y, 1.0)* m;
return vec2(uv.x,uv.y);
}
void main () {
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
// texture.inc 核心函数
// o = texture2D(texture, v_uv0);
// texture: 纹理v_uv0: 纹理坐标,通过 GLSL 的内建函数 texture2D 来获取纹理上对应UV坐标的颜色(RGBA)
o = texture2D(texture, v_uv0);
#endif
// 纹理颜色和顶点颜色(节点颜色)叠加得到最终颜色
o *= v_color;
// alpha-test.inc 核心函数
// if (color.a < alphaThreshold) discard;
// discard退出片段着色器不执行后面的片段着色操作片段也不会写入帧缓冲区
ALPHA_TEST(o);
// 在底图不透明的地方叠加流光纹理的颜色
if(o.a >= 1.0) {
// 根据时间设置流光纹理的UV
vec2 fluxayUV = vec2(v_uv0.x, v_uv0.y);
//fluxayUV.x -= u_time - 1.0;
fluxayUV.x -= u_time;
fluxayUV = transformUV(fluxayUV,u_angle);
if(fluxayUV.x > 0.0 && fluxayUV.x <u_scale)
{
// 获取流光纹理上UV的颜色
fluxayUV.x = fluxayUV.x / u_scale;
//fluxayUV = transformUV(fluxayUV,u_angle);
vec4 fluxay = texture2D(u_fluxayTexture, fluxayUV);
o.a = fluxay.a;
// 叠加颜色
gl_FragColor = o;
}
else {
o.a = 0.0;
gl_FragColor = o;
}
} else {
o.a = 0.0;
gl_FragColor = o;
}
}
}%

View File

@ -0,0 +1,18 @@
{
"ver": "1.0.27",
"uuid": "70ca6f7c-88f0-44f1-9ab3-3b1c0d042995",
"importer": "effect",
"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\n attribute vec2 a_uv0;\n varying vec2 v_uv0;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\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;\nvarying vec2 v_uv0;\nuniform sampler2D texture;\nuniform sampler2D u_fluxayTexture;\nuniform float u_time;\nuniform float u_scale;\nuniform float u_angle;\nvec2 transformUV(vec2 UV,float angle){\n float rotate = (angle * 3.1415926) / 180.0;\n vec2 di = vec2(0.5, 0.5);\n mat3 m = mat3(cos(rotate), -sin(rotate), 0.0,sin(rotate), cos(rotate), 0.0,0.0, 0.0, 1.0);\n vec3 uv = vec3(UV.x,UV.y, 1.0)* m;\n return vec2(uv.x,uv.y);\n}\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o = texture2D(texture, v_uv0);\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n if(o.a >= 1.0) {\n vec2 fluxayUV = vec2(v_uv0.x, v_uv0.y);\n fluxayUV.x -= u_time;\n fluxayUV = transformUV(fluxayUV,u_angle);\n if(fluxayUV.x > 0.0 && fluxayUV.x <u_scale)\n {\n fluxayUV.x = fluxayUV.x / u_scale;\n vec4 fluxay = texture2D(u_fluxayTexture, fluxayUV);\n o.a = fluxay.a;\n gl_FragColor = o;\n }\n else {\n o.a = 0.0;\n gl_FragColor = o;\n }\n } else {\n o.a = 0.0;\n gl_FragColor = o;\n }\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\n in vec2 a_uv0;\n out vec2 v_uv0;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\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;\nin vec2 v_uv0;\nuniform sampler2D texture;\nuniform sampler2D u_fluxayTexture;\nuniform ARGS {\n float u_time;\n float u_scale;\n float u_angle;\n};\nvec2 transformUV(vec2 UV,float angle){\n float rotate = (angle * 3.1415926) / 180.0;\n vec2 di = vec2(0.5, 0.5);\n mat3 m = mat3(cos(rotate), -sin(rotate), 0.0,sin(rotate), cos(rotate), 0.0,0.0, 0.0, 1.0);\n vec3 uv = vec3(UV.x,UV.y, 1.0)* m;\n return vec2(uv.x,uv.y);\n}\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o = texture2D(texture, v_uv0);\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n if(o.a >= 1.0) {\n vec2 fluxayUV = vec2(v_uv0.x, v_uv0.y);\n fluxayUV.x -= u_time;\n fluxayUV = transformUV(fluxayUV,u_angle);\n if(fluxayUV.x > 0.0 && fluxayUV.x <u_scale)\n {\n fluxayUV.x = fluxayUV.x / u_scale;\n vec4 fluxay = texture2D(u_fluxayTexture, fluxayUV);\n o.a = fluxay.a;\n gl_FragColor = o;\n }\n else {\n o.a = 0.0;\n gl_FragColor = o;\n }\n } else {\n o.a = 0.0;\n gl_FragColor = o;\n }\n}"
}
}
],
"subMetas": {}
}

View File

@ -0,0 +1,22 @@
{
"__type__": "cc.Material",
"_name": "fluxay_texture_angle",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "70ca6f7c-88f0-44f1-9ab3-3b1c0d042995"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"props": {
"u_fluxayTexture": {
"__uuid__": "d480c86c-c0a4-49ba-8b45-5f00deb51178"
}
},
"defines": {
"USE_TEXTURE": true
}
}
}
}

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.5",
"uuid": "6b74e4c6-15c5-4566-8dd4-fa523a15898b",
"importer": "material",
"dataAsSubAsset": null,
"subMetas": {}
}

View File

@ -0,0 +1,172 @@
//扫光-纹理
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_fluxayTexture: { value: white }
u_time: { value: 0 }
u_scale: { value: 1.0 }
u_angle: { value: 30.0 }
u_uvRotated: { value: 0.0 }
u_uvOffset: { value: [0.0,0.0,1.0,1.0] }
}%
// Vertex Shader(顶点着色器)
// 将顶点从模型空间坐标系统转化到屏幕空间坐标系统
// 顶点着色器分为输入和输出两部分
// 负责的功能是把输入的数据进行矩阵变换位置,计算光照公式生成逐顶点颜⾊,⽣成/变换纹理坐标
// 并且把位置和纹理坐标这样的参数发送到片段着色器
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
// 输入的纹理坐标
// UV坐标原点在左上角u轴是向右v轴是向下范围是0-1
in vec2 a_uv0;
// 输出的纹理坐标
out vec2 v_uv0;
#endif
void main () {
mat4 mvp;
#if CC_USE_MODEL
mvp = cc_matViewProj * cc_matWorld;
#else
mvp = cc_matViewProj;
#endif
v_uv0 = a_uv0;
v_color = a_color;
gl_Position = mvp * vec4(a_position, 1);
}
}%
// Fragment Shader(片段着色器)
// 片元着色器的作用是处理由光栅化阶段生成的每个片元,最终计算出每个像素的最终颜色(RGBA)
CCProgram fs %{
precision highp float;
#include <alpha-test>
#include <texture>
in vec4 v_color;
in vec2 v_uv0;
uniform sampler2D texture;
uniform sampler2D u_fluxayTexture; //流光纹理
// 自定义属性
// 所有非 sampler 的 uniform 都必须以 UBO 形式声明
// UBO 成员声明类型和顺序有严格的校验机制,以排除 GL 标准下隐式布局对齐带来的内存消耗
// u_uvRotated图片是否旋转
// u_uvOffset 图片minx,miny,maxx,maxy
uniform ARGS {
float u_time;
float u_scale;
float u_angle;
float u_uvRotated;
vec4 u_uvOffset;
};
vec2 transformUV(vec2 UV,float angle){
float rotate = (angle * 3.1415926) / 180.0;
vec2 di = vec2(0.5, 0.5); // 旋转的中心位置
//float a = cos(rotate);
mat3 m = mat3(cos(rotate), -sin(rotate), 0.0,sin(rotate), cos(rotate), 0.0,0.0, 0.0, 1.0);
//vec3 uv = vec3(UV.x-di.x,UV.y+di.y, 1.0)* m;
//return vec2(uv.x,uv.y)+vec2(di.x,-di.y);
vec3 uv = vec3(UV.x,UV.y, 1.0)* m;
return vec2(uv.x,uv.y);
}
void main () {
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
// texture.inc 核心函数
// o = texture2D(texture, v_uv0);
// texture: 纹理v_uv0: 纹理坐标,通过 GLSL 的内建函数 texture2D 来获取纹理上对应UV坐标的颜色(RGBA)
o = texture2D(texture, v_uv0);
#endif
// 纹理颜色和顶点颜色(节点颜色)叠加得到最终颜色
o *= v_color;
// alpha-test.inc 核心函数
// if (color.a < alphaThreshold) discard;
// discard退出片段着色器不执行后面的片段着色操作片段也不会写入帧缓冲区
ALPHA_TEST(o);
//纹理的xMin
float xMin = u_uvOffset.x;
float xWidth = u_uvOffset.z - u_uvOffset.x;
//x 转换成扫光图片上的位置
float x = (v_uv0.x - xMin)/xWidth;
float yMin = u_uvOffset.y;
float yWidth = u_uvOffset.w- u_uvOffset.y;
//y 转换成扫光图片上的位置
float y = (v_uv0.y - yMin)/yWidth;
float angle = u_angle;
if(u_uvRotated >= 1.0)
{
x = (v_uv0.y - yMin)/yWidth;
y = (v_uv0.x - xMin)/xWidth;
angle = -u_angle;
}
// 在底图不透明的地方叠加流光纹理的颜色
if(o.a >= 1.0) {
// 根据时间设置流光纹理的UV
vec2 fluxayUV = vec2(x, y);
x += u_scale;
float time = u_time*(1.0+u_scale);
//if(fluxayUV.x > u_time-u_scale && fluxayUV.x <u_time)
if(o.a >= 1.0)
{
// 获取流光纹理上UV的颜色
fluxayUV.x = (x-time)/ u_scale;
fluxayUV = transformUV(fluxayUV,angle);
vec4 fluxay = texture2D(u_fluxayTexture, fluxayUV);
o.a = fluxay.a;
// 叠加颜色
gl_FragColor = o;
}
else {
o.a = 0.0;
gl_FragColor = o;
}
} else {
o.a = 0.0;
gl_FragColor = o;
}
}
}%

View File

@ -0,0 +1,18 @@
{
"ver": "1.0.27",
"uuid": "ccd9fbe1-b0af-4e37-966a-18927c87f434",
"importer": "effect",
"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\n attribute vec2 a_uv0;\n varying vec2 v_uv0;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\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;\nvarying vec2 v_uv0;\nuniform sampler2D texture;\nuniform sampler2D u_fluxayTexture;\nuniform float u_time;\nuniform float u_scale;\nuniform float u_angle;\nuniform float u_uvRotated;\nuniform vec4 u_uvOffset;\nvec2 transformUV(vec2 UV,float angle){\n float rotate = (angle * 3.1415926) / 180.0;\n vec2 di = vec2(0.5, 0.5);\n mat3 m = mat3(cos(rotate), -sin(rotate), 0.0,sin(rotate), cos(rotate), 0.0,0.0, 0.0, 1.0);\n vec3 uv = vec3(UV.x,UV.y, 1.0)* m;\n return vec2(uv.x,uv.y);\n}\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o = texture2D(texture, v_uv0);\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n float xMin = u_uvOffset.x;\n float xWidth = u_uvOffset.z - u_uvOffset.x;\n float x = (v_uv0.x - xMin)/xWidth;\n float yMin = u_uvOffset.y;\n float yWidth = u_uvOffset.w- u_uvOffset.y;\n float y = (v_uv0.y - yMin)/yWidth;\n float angle = u_angle;\n if(u_uvRotated >= 1.0)\n {\n x = (v_uv0.y - yMin)/yWidth;\n y = (v_uv0.x - xMin)/xWidth;\n angle = -u_angle;\n }\n if(o.a >= 1.0) {\n vec2 fluxayUV = vec2(x, y);\n x += u_scale;\n float time = u_time*(1.0+u_scale);\n if(o.a >= 1.0)\n {\n fluxayUV.x = (x-time)/ u_scale;\n fluxayUV = transformUV(fluxayUV,angle);\n vec4 fluxay = texture2D(u_fluxayTexture, fluxayUV);\n o.a = fluxay.a;\n gl_FragColor = o;\n }\n else {\n o.a = 0.0;\n gl_FragColor = o;\n }\n } else {\n o.a = 0.0;\n gl_FragColor = o;\n }\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\n in vec2 a_uv0;\n out vec2 v_uv0;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\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;\nin vec2 v_uv0;\nuniform sampler2D texture;\nuniform sampler2D u_fluxayTexture;\nuniform ARGS {\n float u_time;\n float u_scale;\n float u_angle;\n float u_uvRotated;\n vec4 u_uvOffset;\n};\nvec2 transformUV(vec2 UV,float angle){\n float rotate = (angle * 3.1415926) / 180.0;\n vec2 di = vec2(0.5, 0.5);\n mat3 m = mat3(cos(rotate), -sin(rotate), 0.0,sin(rotate), cos(rotate), 0.0,0.0, 0.0, 1.0);\n vec3 uv = vec3(UV.x,UV.y, 1.0)* m;\n return vec2(uv.x,uv.y);\n}\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o = texture2D(texture, v_uv0);\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n float xMin = u_uvOffset.x;\n float xWidth = u_uvOffset.z - u_uvOffset.x;\n float x = (v_uv0.x - xMin)/xWidth;\n float yMin = u_uvOffset.y;\n float yWidth = u_uvOffset.w- u_uvOffset.y;\n float y = (v_uv0.y - yMin)/yWidth;\n float angle = u_angle;\n if(u_uvRotated >= 1.0)\n {\n x = (v_uv0.y - yMin)/yWidth;\n y = (v_uv0.x - xMin)/xWidth;\n angle = -u_angle;\n }\n if(o.a >= 1.0) {\n vec2 fluxayUV = vec2(x, y);\n x += u_scale;\n float time = u_time*(1.0+u_scale);\n if(o.a >= 1.0)\n {\n fluxayUV.x = (x-time)/ u_scale;\n fluxayUV = transformUV(fluxayUV,angle);\n vec4 fluxay = texture2D(u_fluxayTexture, fluxayUV);\n o.a = fluxay.a;\n gl_FragColor = o;\n }\n else {\n o.a = 0.0;\n gl_FragColor = o;\n }\n } else {\n o.a = 0.0;\n gl_FragColor = o;\n }\n}"
}
}
],
"subMetas": {}
}

View File

@ -0,0 +1,22 @@
{
"__type__": "cc.Material",
"_name": "fluxay_texture_angle2",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "ccd9fbe1-b0af-4e37-966a-18927c87f434"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {
"USE_TEXTURE": true
},
"props": {
"u_fluxayTexture": {
"__uuid__": "afa85bd2-7b47-4171-b74f-2e72c7cbb9ff"
}
}
}
}
}

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.5",
"uuid": "2e1288a2-ace1-42df-8d05-bf74722fa478",
"importer": "material",
"dataAsSubAsset": null,
"subMetas": {}
}

View File

@ -0,0 +1,104 @@
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
# 描边颜色
outlineColor: {
value: [1.0, 0.0, 0.0, 1.0],
editor: {
type: color,
tooltip: "描边颜色",
}
}
fntColor: {
value: [1.0, 0.0, 0.0, 1.0],
editor: {
type: color,
tooltip: "字体颜色",
}
}
}%
CCProgram vs %{
precision highp float;
#include <cc-global>
in vec3 a_position;
in mediump vec2 a_uv0;
out mediump vec2 v_uv0;
in vec4 a_color;
out vec4 v_color;
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
v_uv0 = a_uv0;
v_color = a_color;
}
}%
CCProgram fs %{
precision highp float;
#include <texture>
uniform sampler2D texture;
in mediump vec2 v_uv0;
in vec4 v_color;
#if SHOW_OUT_LINE
uniform Outline {
// 描边颜色
vec4 outlineColor;
// 字体颜色
vec4 fntColor;
};
#endif
void main () {
vec4 color = v_color;
CCTexture(texture, v_uv0, color);
//float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;
float temp = 1.0;
if(color.a == 0.0)
{
}
if(color.r ==1.0 && color.g ==1.0 && color.b == 1.0 )
{
color = vec4(fntColor.r*temp, fntColor.g*temp, fntColor.b*temp, color.a);
}
else if(color.r ==0.0 && color.g ==0.0 && color.b == 0.0)
{
color = vec4(outlineColor.r*temp, outlineColor.g*temp, outlineColor.b*temp, color.a);
}
else
{
temp = 1.0-(color.r /1.0 + color.g / 1.0 + color.b /1.0)/3.0;
color = vec4(outlineColor.r*temp+(fntColor.r)*(1.0-temp), outlineColor.g*temp+(fntColor.g)*(1.0-temp), outlineColor.b*temp+(fntColor.b)*(1.0-temp), color.a);
//color = outlineColor.r*temp + vec4(1.0,1.0,1.0,1.0)*(1.0-temp);
}
gl_FragColor =color;
}
}%

View File

@ -0,0 +1,18 @@
{
"ver": "1.0.27",
"uuid": "a8d4595f-5f4f-4b84-a3b7-988103168a7a",
"importer": "effect",
"compiledShaders": [
{
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 v_uv0;\nattribute vec4 a_color;\nvarying vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nvarying mediump vec2 v_uv0;\nvarying vec4 v_color;\n#if SHOW_OUT_LINE\n uniform vec4 outlineColor;\nuniform vec4 fntColor;\n#endif\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float temp = 1.0;\n if(color.a == 0.0)\n {\n }\n if(color.r ==1.0 && color.g ==1.0 && color.b == 1.0 )\n {\n color = vec4(fntColor.r*temp, fntColor.g*temp, fntColor.b*temp, color.a);\n }\n else if(color.r ==0.0 && color.g ==0.0 && color.b == 0.0)\n {\n color = vec4(outlineColor.r*temp, outlineColor.g*temp, outlineColor.b*temp, color.a);\n }\n else\n {\n temp = 1.0-(color.r /1.0 + color.g / 1.0 + color.b /1.0)/3.0;\n color = vec4(outlineColor.r*temp+(fntColor.r)*(1.0-temp), outlineColor.g*temp+(fntColor.g)*(1.0-temp), outlineColor.b*temp+(fntColor.b)*(1.0-temp), color.a);\n }\n gl_FragColor =color;\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};\nin vec3 a_position;\nin mediump vec2 a_uv0;\nout mediump vec2 v_uv0;\nin vec4 a_color;\nout vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nin mediump vec2 v_uv0;\nin vec4 v_color;\n#if SHOW_OUT_LINE\n uniform Outline {\n vec4 outlineColor;\n vec4 fntColor;\n };\n#endif\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float temp = 1.0;\n if(color.a == 0.0)\n {\n }\n if(color.r ==1.0 && color.g ==1.0 && color.b == 1.0 )\n {\n color = vec4(fntColor.r*temp, fntColor.g*temp, fntColor.b*temp, color.a);\n }\n else if(color.r ==0.0 && color.g ==0.0 && color.b == 0.0)\n {\n color = vec4(outlineColor.r*temp, outlineColor.g*temp, outlineColor.b*temp, color.a);\n }\n else\n {\n temp = 1.0-(color.r /1.0 + color.g / 1.0 + color.b /1.0)/3.0;\n color = vec4(outlineColor.r*temp+(fntColor.r)*(1.0-temp), outlineColor.g*temp+(fntColor.g)*(1.0-temp), outlineColor.b*temp+(fntColor.b)*(1.0-temp), color.a);\n }\n gl_FragColor =color;\n}"
}
}
],
"subMetas": {}
}

View File

@ -0,0 +1,33 @@
{
"__type__": "cc.Material",
"_name": "fntOutline",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "a8d4595f-5f4f-4b84-a3b7-988103168a7a"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"props": {
"outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"fntColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
}
},
"defines": {
"SHOW_OUT_LINE": true
}
}
}
}

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.5",
"uuid": "ff207936-86fd-4d7a-93af-1a930cf6c6c2",
"importer": "material",
"dataAsSubAsset": null,
"subMetas": {}
}

View File

@ -0,0 +1,104 @@
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { 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;
#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;
gl_Position = pos;
}
}%
CCProgram fs %{
precision highp float;
#include <cc-global>
#include <alpha-test>
#include <texture>
in vec4 v_color;
#if USE_TEXTURE
in vec2 v_uv0;
uniform sampler2D texture;
#endif
vec2 getSt(){
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
CCTexture(texture, v_uv0, o);
#endif
o *= v_color;
ALPHA_TEST(o);
return v_uv0;
}
void main () {
vec2 st = getSt();
vec2 uv = st;
//设置中心点
vec2 position = vec2(0.5) - st;
float time = cc_time.x;
//灯光强度
float strength = 0.2;
//太阳大小
float scale = 8.0;
float l = abs(sin(1.1)*0.1) / length(position);
float l2 = abs(sin(1.2)*0.1) / length(position);
float l3 = abs(sin(1.3)*0.1) / length(position);
vec4 fragColor = vec4(l,l2,l3, 1.0);
gl_FragColor = scale * vec4(fragColor.xyz,smoothstep(strength,1.0,fragColor.xyz));
}
}%

View File

@ -0,0 +1,18 @@
{
"ver": "1.0.27",
"uuid": "81f30e9d-18f4-47fa-b5db-f0a0d38c382a",
"importer": "effect",
"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;\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 gl_Position = pos;\n}",
"frag": "\nprecision highp float;\nuniform vec4 cc_time;\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;\nuniform sampler2D texture;\n#endif\nvec2 getSt(){\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n return v_uv0;\n}\nvoid main () {\n vec2 st = getSt();\n vec2 uv = st;\n vec2 position = vec2(0.5) - st;\n float time = cc_time.x;\n float strength = 0.2;\n float scale = 8.0;\n float l = abs(sin(1.1)*0.1) / length(position);\n float l2 = abs(sin(1.2)*0.1) / length(position);\n float l3 = abs(sin(1.3)*0.1) / length(position);\n vec4 fragColor = vec4(l,l2,l3, 1.0);\n gl_FragColor = scale * vec4(fragColor.xyz,smoothstep(strength,1.0,fragColor.xyz));\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;\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 gl_Position = pos;\n}",
"frag": "\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};\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;\nuniform sampler2D texture;\n#endif\nvec2 getSt(){\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n return v_uv0;\n}\nvoid main () {\n vec2 st = getSt();\n vec2 uv = st;\n vec2 position = vec2(0.5) - st;\n float time = cc_time.x;\n float strength = 0.2;\n float scale = 8.0;\n float l = abs(sin(1.1)*0.1) / length(position);\n float l2 = abs(sin(1.2)*0.1) / length(position);\n float l3 = abs(sin(1.3)*0.1) / length(position);\n vec4 fragColor = vec4(l,l2,l3, 1.0);\n gl_FragColor = scale * vec4(fragColor.xyz,smoothstep(strength,1.0,fragColor.xyz));\n}"
}
}
],
"subMetas": {}
}

View File

@ -0,0 +1,17 @@
{
"__type__": "cc.Material",
"_name": "shader_005M",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "81f30e9d-18f4-47fa-b5db-f0a0d38c382a"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {
"USE_TEXTURE": true
}
}
}
}

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.5",
"uuid": "4ceedcc6-0953-4a13-9caf-3a6ceee025ed",
"importer": "material",
"dataAsSubAsset": null,
"subMetas": {}
}

13
assets/Texture.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 195,
"height": 270,
"platformSettings": {},
"subMetas": {
"HelloWorld": {
"ver": "1.0.6",
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
"importer": "sprite-frame",
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 195,
"height": 270,
"rawWidth": 195,
"rawHeight": 270,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2,
"height": 2,
"platformSettings": {},
"subMetas": {
"singleColor": {
"ver": "1.0.6",
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
"importer": "sprite-frame",
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2,
"height": 2,
"rawWidth": 2,
"rawHeight": 2,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

13
assets/animation.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "7c1d6faa-66b9-4423-aa04-8c38a15768cf",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,29 @@
{
"__type__": "cc.AnimationClip",
"_name": "action1",
"_objFlags": 0,
"_native": "",
"_duration": 0.6666666666666666,
"sample": 60,
"speed": 0.1,
"wrapMode": 38,
"curveData": {
"props": {
"angle": [
{
"frame": 0,
"value": 0
},
{
"frame": 0.3333333333333333,
"value": 180
},
{
"frame": 0.6666666666666666,
"value": 360
}
]
}
},
"events": []
}

View File

@ -0,0 +1,6 @@
{
"ver": "2.1.2",
"uuid": "dd9d69fc-bc3c-4239-968e-9c6f4e54d9cf",
"importer": "animation-clip",
"subMetas": {}
}

13
assets/migration.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "2e3d6223-9889-4122-8121-c6d837f5367e",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,17 @@
/*
* This script is automatically generated by Cocos Creator and is only used for projects compatible with the v2.1.0 2.2.1 version.
* You do not need to manually add this script in any other project.
* If you don't use cc.Toggle in your project, you can delete this script directly.
* If your project is hosted in VCS such as git, submit this script together.
*
* 此脚本由 Cocos Creator 自动生成仅用于兼容 v2.1.0 ~ 2.2.1 版本的工程
* 你无需在任何其它项目中手动添加此脚本
* 如果你的项目中没用到 Toggle可直接删除该脚本
* 如果你的项目有托管于 git 等版本库请将此脚本一并上传
*/
if (cc.Toggle) {
// Whether to trigger 'toggle' and 'checkEvents' events when modifying 'toggle.isChecked' in the code
// 在代码中修改 'toggle.isChecked' 时是否触发 'toggle' 与 'checkEvents' 事件
cc.Toggle._triggerEventInScript_isChecked = true;
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "7a231473-d1df-4b05-8620-6376c36252c1",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/music.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "6ebfe2d9-539a-4853-8b16-fca5c89cf2ce",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

BIN
assets/music/arrow.mp3 Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"ver": "2.0.3",
"uuid": "8e64e6d7-d5e8-4990-a537-191fe13e0c9a",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.444082,
"subMetas": {}
}

BIN
assets/music/score.mp3 Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"ver": "2.0.3",
"uuid": "e70b3103-83f1-4c66-9093-1897c1a5d4ae",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.444082,
"subMetas": {}
}

BIN
assets/music/whoosh.mp3 Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"ver": "2.0.3",
"uuid": "23088b7e-3d20-4130-9a29-36da5b7df5e1",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.20898,
"subMetas": {}
}

13
assets/prefab.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "bf3935ca-518a-42f4-84e4-ad96badfd1b4",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

5454
assets/prefab/Canvas.prefab Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
{
"ver": "1.3.2",
"uuid": "1f9265d6-31fa-4638-be80-340517745006",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

Some files were not shown because too many files have changed in this diff Show More