修改特效展示
This commit is contained in:
parent
28b648bc9d
commit
6357fa0c35
|
|
@ -165,6 +165,11 @@ export default class MapConroler extends cc.Component {
|
||||||
// mapInfo: number[][] = [];
|
// mapInfo: number[][] = [];
|
||||||
getProgressLevel: number = 0;
|
getProgressLevel: number = 0;
|
||||||
getProgress: number = 0;
|
getProgress: number = 0;
|
||||||
|
|
||||||
|
private magicEffectIndex: number = 0;
|
||||||
|
private magicEffect1: cc.Node = null; // 第一套特效节点
|
||||||
|
private magicEffect2: cc.Node = null; // 第二套特效节点
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
|
||||||
MiniGameSdk.API.setNewCloudlevel();
|
MiniGameSdk.API.setNewCloudlevel();
|
||||||
|
|
@ -3114,6 +3119,22 @@ export default class MapConroler extends cc.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initMagicEffects() {
|
||||||
|
// 初始化两个特效节点,如果还没有创建的话
|
||||||
|
if (!this.magicEffect1) {
|
||||||
|
this.magicEffect1 = this.magics; // 第一个特效使用原来的节点
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.magicEffect2) {
|
||||||
|
// 创建第二个特效节点,复制第一个的结构
|
||||||
|
this.magicEffect2 = cc.instantiate(this.magics);
|
||||||
|
this.magicEffect2.parent = this.magics.parent;
|
||||||
|
// 确保第二个特效初始状态是隐藏的
|
||||||
|
this.magicEffect2.active = false;
|
||||||
|
this.magicEffect2.setPosition(this.magics.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//使用魔法棒随机消除两个方块
|
//使用魔法棒随机消除两个方块
|
||||||
useMagic() {
|
useMagic() {
|
||||||
if (this.gameOver == true || this.gameWin == true) {
|
if (this.gameOver == true || this.gameWin == true) {
|
||||||
|
|
@ -3173,10 +3194,19 @@ export default class MapConroler extends cc.Component {
|
||||||
magicBtn.getComponent("btnControl").setTouch(true);
|
magicBtn.getComponent("btnControl").setTouch(true);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
// 初始化两个特效节点
|
||||||
|
this.initMagicEffects();
|
||||||
|
|
||||||
//魔法棒
|
//魔法棒
|
||||||
this.ismagic = true;
|
this.ismagic = true;
|
||||||
this.magics.active = true;
|
|
||||||
this.magics.scale = 1;
|
// 根据索引选择要使用的特效节点
|
||||||
|
const currentEffect = this.magicEffectIndex % 2 === 0 ? this.magicEffect1 : this.magicEffect2;
|
||||||
|
this.magicEffectIndex = (this.magicEffectIndex + 1) % 2; // 更新索引
|
||||||
|
|
||||||
|
currentEffect.active = true;
|
||||||
|
currentEffect.scale = 1;
|
||||||
|
|
||||||
const path = [
|
const path = [
|
||||||
{
|
{
|
||||||
"x": -522.8444229452174,
|
"x": -522.8444229452174,
|
||||||
|
|
@ -3431,42 +3461,46 @@ export default class MapConroler extends cc.Component {
|
||||||
|
|
||||||
const smoothPts = this.getSmoothPath(pts, 10); //
|
const smoothPts = this.getSmoothPath(pts, 10); //
|
||||||
|
|
||||||
// this.magics.setPosition(smoothPts[0]);
|
|
||||||
|
|
||||||
let totalLen = 0;
|
let totalLen = 0;
|
||||||
let lens: number[] = [];
|
let lens: number[] = [];
|
||||||
|
|
||||||
|
|
||||||
// 1. 先把节点/粒子立即隐藏并复位
|
// 1. 先把节点/粒子立即隐藏并复位
|
||||||
this.magics.stopAllActions(); // 立即停止旧动画
|
currentEffect.stopAllActions(); // 立即停止旧动画
|
||||||
this.magics.setPosition(smoothPts[0]); // 必须在一开始就先放到起点
|
currentEffect.setPosition(smoothPts[0]); // 必须在一开始就先放到起点
|
||||||
this.magics.active = true; // 保证节点可见
|
|
||||||
this.magics.children[0].children[2].active = false; // 先关粒子
|
// 获取粒子系统组件
|
||||||
this.magics.children[0].children[3].active = false;
|
const particle1 = currentEffect.children[0].children[2];
|
||||||
|
const particle2 = currentEffect.children[0].children[3];
|
||||||
|
const p1 = particle1.getComponent(cc.ParticleSystem);
|
||||||
|
const p2 = particle2.getComponent(cc.ParticleSystem);
|
||||||
|
|
||||||
|
// 先关闭所有粒子显示
|
||||||
|
particle1.active = false;
|
||||||
|
particle2.active = false;
|
||||||
|
|
||||||
|
p1 && p1.stopSystem(); // true 表示立即清零
|
||||||
|
p2 && p2.stopSystem();
|
||||||
|
|
||||||
for (let i = 1; i < smoothPts.length; i++) {
|
for (let i = 1; i < smoothPts.length; i++) {
|
||||||
const len = smoothPts[i].sub(smoothPts[i - 1]).mag();
|
const len = smoothPts[i].sub(smoothPts[i - 1]).mag();
|
||||||
lens.push(len);
|
lens.push(len);
|
||||||
totalLen += len;
|
totalLen += len;
|
||||||
}
|
}
|
||||||
// 1. 立即停止并清零粒子
|
|
||||||
const p1 = this.magics.children[0].children[2].getComponent(cc.ParticleSystem);
|
|
||||||
const p2 = this.magics.children[0].children[3].getComponent(cc.ParticleSystem);
|
|
||||||
p1 && p1.stopSystem(); // true 表示立即清零
|
|
||||||
p2 && p2.stopSystem();
|
|
||||||
|
|
||||||
// 2. 把节点放到起点
|
// 2. 把节点放到起点
|
||||||
this.magics.stopAllActions();
|
currentEffect.stopAllActions();
|
||||||
this.magics.setPosition(smoothPts[0]);
|
currentEffect.setPosition(smoothPts[0]);
|
||||||
|
|
||||||
// 3. 下一帧再重新播放
|
// 3. 下一帧再重新播放
|
||||||
this.scheduleOnce(() => {
|
this.scheduleOnce(() => {
|
||||||
p1 && p1.resetSystem(); // 重置到初始状态再播放
|
p1 && p1.resetSystem(); // 重置到初始状态再播放
|
||||||
p2 && p2.resetSystem();
|
p2 && p2.resetSystem();
|
||||||
this.magics.children[0].children[2].active = true;
|
particle1.active = true;
|
||||||
this.magics.children[0].children[3].active = true;
|
particle2.active = true;
|
||||||
|
|
||||||
// 4. tween 动画
|
// 4. tween 动画
|
||||||
let t = cc.tween(this.magics);
|
let t = cc.tween(currentEffect);
|
||||||
for (let i = 1; i < smoothPts.length; i++) {
|
for (let i = 1; i < smoothPts.length; i++) {
|
||||||
const segDur = totalDur * (lens[i - 1] / totalLen);
|
const segDur = totalDur * (lens[i - 1] / totalLen);
|
||||||
t = t.to(segDur, { position: smoothPts[i] });
|
t = t.to(segDur, { position: smoothPts[i] });
|
||||||
|
|
@ -3474,12 +3508,12 @@ export default class MapConroler extends cc.Component {
|
||||||
t.delay(0.5).call(() => {
|
t.delay(0.5).call(() => {
|
||||||
p1 && p1.stopSystem(); // 结束后再停
|
p1 && p1.stopSystem(); // 结束后再停
|
||||||
p2 && p2.stopSystem();
|
p2 && p2.stopSystem();
|
||||||
this.magics.children[0].children[2].active = false;
|
particle1.active = false;
|
||||||
this.magics.children[0].children[3].active = false;
|
particle2.active = false;
|
||||||
}).to(0.15, { scale: 0 })
|
}).to(0.15, { scale: 0 })
|
||||||
.call(() => {
|
.call(() => {
|
||||||
this.magics.setPosition(-900, -700, 0);
|
currentEffect.setPosition(-900, -700, 0);
|
||||||
this.magics.active = false;
|
currentEffect.active = false;
|
||||||
})
|
})
|
||||||
.start();
|
.start();
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user