Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李楚霏
/
MyWork
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cc52369d
authored
Nov 22, 2019
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1121
parent
9eee8c34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
264 additions
and
0 deletions
+264
-0
恐龙进化狂点有倒计时版
+264
-0
No files found.
恐龙进化狂点有倒计时版
0 → 100644
View file @
cc52369d
/**
/**
* Copyright (c) 2019 AnyGame. All rights reserved.
*/
let panelManager = null;
const panel = require('panel');
const panelLogic = require('crazyHitLogic');
const banner = require('banner');
const manager = require('manager');
cc.Class({
extends: panel,
properties: {
countdown: {
type: cc.Label,
default: null,
tooltip: '倒计时',
},
win: {
type: cc.Node,
default: null,
tooltip: '胜利提示',
},
final: {
type: cc.Node,
default: null,
tooltip: '最终结果',
},
title: {
type: cc.Node,
default: null,
tooltip: '正常提示',
},
meatPrefab: {
default: null,
type: cc.Prefab,
tooltip: '肉节点',
},
crazyBar: cc.ProgressBar, // 进度条
crazyBtn: cc.Node, // 疯狂点击按钮
ndCrazy: cc.Node, // 管理疯狂点击的节点
ndBtnGet: cc.Node, // 普通领取按钮
dinosaurNode: { //恐龙
default: null,
type: cc.Node,
tooltip: "恐龙"
},
levelPreb: cc.Prefab, //经验值动画
},
onLoad() {
panelManager = require('panelManager');
//this.ndBtnGetY = this.ndBtnGet.y;
this.dinosaur = this.dinosaurNode.getComponent('dinosaurCrazy');
this.dinosaur.init();
this.posArray = []; /* 记录元素位置坐标 */
this.meats = [];
var x = 0;
var y = 10;
for (let index = 0; index < 4; index++) {
var meat = cc.instantiate(this.meatPrefab);
this.meats.push(meat);
meat.setPosition(cc.v2(x, y));
x = this.meats[index].x + 100;
var pos = meat.position;
this.posArray.push(pos);
cc.log("init:" + this.meats[index].position);
this.node.addChild(meat);
}
},
onEnable() {
// this.watch 接口 调用
},
/**
* 界面显示时相关逻辑接口
*/
show(params) {
this.unscheduleAllCallbacks();
require('manager').sendEvent('界面曝光-大按钮狂点');
if (params) {
this.callback = params.callback;
}
this.meatNum = 0; /* 吃肉的个数 */
this.crazyBar.progress = 0;
//this.time = 5;
//this.countdown.string = this.time;
this.win.active = false;
this.final.active = false;
this.title.active = true;
this.ndBtnGet.active = false;
this.ndCrazy.active = true;
//this.countdown.node.active = true;
this.startCutProgress = false;
},
cutProgress() {
//this.time--;
// if (this.time < 0) {
this.unschedule(this.cutProgress);
//this.over();
return;
// }
// this.countdown.string = this.time;
},
over(quick) {
require('manager').sendEvent('界面曝光-大按钮狂点-结束');
//this.countdown.node.active = false;
if (this.crazyBar.progress < 0.7) { //0.7
this.title.active = false;
this.final.active = true;
this.win.active = false;
} else {
this.title.active = false;
this.final.active = false;
this.win.active = true;
}
this.ndBtnGet.active = true;
this.ndCrazy.active = false;
this.mistake(quick);
/**
*最终显示吃肉个数
*/
this.win.getComponent('cc.Label').string = '我吃了' + this.meatNum + '个肉';
},
onCrazyBtnClick() {
if (!this.startCutProgress) {
this.startCutProgress = true;
this.unschedule(this.cutProgress);
this.schedule(this.cutProgress, 1);
}
if (this.eating) {
return;
}
this.eating = true;
let meat = this.meats[0];
let targetPos = cc.v2(meat.x - 100, meat.y);
const moveToAction = cc.moveTo(0.1, targetPos);
let finish = cc.callFunc(() => {
this.eating = false;
meat.position = this.posArray[this.posArray.length - 1];
for (let i = 0; i < this.meats.length; i++) {
if (i === this.meats.length - 1) {
this.meats[i] = meat;
} else {
this.meats[i] = this.meats[i + 1];
}
}
}, this);
var seq = cc.sequence(moveToAction, finish);
meat.runAction(seq);
for (let i = 1; i < this.meats.length; ++i) {
if (!this.meats[i]) {
continue;
}
let targetPos = cc.v2(this.meats[i].x - 100, this.meats[i].y);
const moveToAction = cc.moveTo(0.1, targetPos);
this.meats[i].runAction(moveToAction);
}
const levelNode = cc.instantiate(this.levelPreb);
levelNode.parent = this.dinosaur.node.parent;
let rndPosX = dataFunc.randomNum(-75, 75);
let rndPosY = dataFunc.randomNum(100, 150);
levelNode.position = cc.v2(this.dinosaur.node.x + rndPosX, this.dinosaur.node.y + rndPosY);
const levelPrebMoveToAction = cc.moveBy(1, cc.v2(0, 200));
const levelPrebFadeInAction = cc.fadeOut(1.0);
const levelPrebActionTo = cc.scaleTo(1, 0.5);
let finish2 = cc.callFunc(() => {
levelNode.destroy();
}, this);
var action = cc.spawn(levelPrebMoveToAction, levelPrebFadeInAction, levelPrebActionTo);
var seq = cc.sequence(action, finish2);
levelNode.runAction(seq);
this.dinosaur.updateSelf();
this.meatNum++;
this.crazyBar.progress += this.crazyBar.progress >= 0.7 ? 0.1 : 0.1; //0.7
if (this.crazyBar.progress < 0.2) {
levelNode.getComponent(cc.Label).string = '+1';
PlayerManager.player.addFan(1);
} else if (this.crazyBar.progress < 0.5) {
levelNode.getComponent(cc.Label).string = '+2';
PlayerManager.player.addFan(2);
levelNode.scale = 2;
} else {
levelNode.getComponent(cc.Label).string = '+3';
levelNode.scale = 3;
PlayerManager.player.addFan(3);
if (this.crazyBar.progress > 0.8) { //TODO: 0.75
this.unscheduleAllCallbacks();
this.over(true);
}
}
},
onBtnGetClick() {
require('manager').sendEvent('按钮点击-大按钮狂点-继续游戏');
panelManager.hidePanel('crazyHitPanel');
window.manager.hideAdBanner('gameOverPanel');
if (this.callback && typeof this.callback === 'function') {
this.callback();
this.callback = null;
}
},
mistake(quick) {
if (window.manager.isAreaShield() || quick) {
//this.ndBtnGet.y = this.ndBtnGetY;
window.manager.showAdBanner('大按钮狂点');
} else { // 误触
const p = banner.getBannerHeightCenter();
//this.ndBtnGet.y = p.y;
this.scheduleOnce(() => {
//this.ndBtnGet.y = this.ndBtnGetY;
window.manager.showAdBanner('大按钮狂点-结算');
}, manager.setting.crazyClickDelay || 1);
}
},
update(dt) {
this.crazyBar.progress -= 0.3 * dt;
if (this.crazyBar.progress < 0) {
this.crazyBar.progress = 0;
}
},
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment