Commit 125d7017 authored by 范雪寒's avatar 范雪寒

feat:

parent 3ab677f9
No preview for this file type
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
}
onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
_cantouch = null;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
}
initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
}
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
// update (dt) {},
initListener() {
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
import { defaultData } from "../script/defaultData";
export class MyCocosSceneComponent extends cc.Component {
// 生命周期 onLoad
onLoad() {
this.initSceneData();
this.initSize();
}
_imageResList = null;
_audioResList = null;
_animaResList = null;
initSceneData() {
this._imageResList = [];
this._audioResList = [];
this._animaResList = [];
}
_designSize = null; // 设计分辨率
_frameSize = null; // 屏幕分辨率
_mapScaleMin = null; // 场景中常用缩放(取大值)
_mapScaleMax = null; // 场景中常用缩放(取小值)
_cocosScale = null; // cocos 自缩放 (较少用到)
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
this._designSize = cc.view.getDesignResolutionSize();
let sx = cc.winSize.width / frameSize.width;
let sy = cc.winSize.height / frameSize.height;
this._cocosScale = Math.min(sx, sy);
sx = frameSize.width / this._designSize.width;
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
cc.director['_scene'].width = frameSize.width;
cc.director['_scene'].height = frameSize.height;
}
data = null;
// 生命周期 start
start() {
if (window && (<any>window).courseware && (<any>window).courseware.getData) {
(<any>window).courseware.getData((data) => {
this.log('data:' + data);
this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data));
this.preloadItem();
})
} else {
this.data = this.getDefaultData();
this.preloadItem();
}
}
getDefaultData() {
return defaultData;
}
preloadItem() {
this.addPreloadImage();
this.addPreloadAudio();
this.addPreloadAnima();
this.preload();
}
addPreloadImage() {
}
addPreloadAudio() {
}
addPreloadAnima() {
}
preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
if (window && window["air"]) {
// window["air"].onCourseInScreen = (next) => {
// window["air"].isCourseInScreen = true;
// this.onLoadEnd();
// next();
// };
this.onLoadEnd();
window["air"].hideAirClassLoading();
} else {
this.onLoadEnd();
}
cc.debug.setDisplayStats(false);
});
}
log (str) {
const node = cc.find('middleLayer');
if(node){
node.getComponent('middleLayer').log(str);
}else{
cc.log(str);
}
}
onLoadEnd() {
}
// ------------------------------------------------
getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
node.addComponent(cc.Sprite).spriteFrame = sf;
return node;
}
getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
}
getSprNodeByUrl(url, cb) {
const node = new cc.Node();
const spr = node.addComponent(cc.Sprite);
this.getSpriteFrimeByUrl(url, (sf) => {
spr.spriteFrame = sf;
if (cb) {
cb(node);
}
})
}
playAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
}
}
}
\ No newline at end of file
export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "b54300af-b8e5-4b4e-aa2f-9ac1cef7b598",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export function getPosByAngle(angle, len) {
const radian = angle * Math.PI / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
return { x, y };
}
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor(180 / (Math.PI / radina) * 100) / 100; // 将弧度转换成角度
if (mx > px && my > py) {// 鼠标在第四象限
angle = 180 - angle;
}
if (mx === px && my > py) {// 鼠标在y轴负方向上
angle = 180;
}
if (mx > px && my === py) {// 鼠标在x轴正方向上
angle = 90;
}
if (mx < px && my > py) {// 鼠标在第三象限
angle = 180 + angle;
}
if (mx < px && my === py) {// 鼠标在x轴负方向
angle = 270;
}
if (mx < px && my < py) {// 鼠标在第二象限
angle = 360 - angle;
}
// console.log('angle: ', angle);
return angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
}
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
}
export function setSprNodeMaxLen(sprNode, maxW, maxH) {
const sx = maxW / sprNode.width;
const sy = maxH / sprNode.height;
const s = Math.min(sx, sy);
sprNode.scale = Math.round(s * 1000) / 1000;
}
export function localPosTolocalPos(baseNode, targetNode) {
const worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function worldPosToLocalPos(worldPos, baseNode) {
const localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
return localPos;
}
export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
const worldRect1 = targetNode.getBoundingBoxToWorld();
const worldRect2 = baseNode.getBoundingBoxToWorld();
const sx = worldRect1.width / worldRect2.width;
const sy = worldRect1.height / worldRect2.height;
if (maxFlag) {
return Math.max(sx, sy);
} else {
return Math.min(sx, sy);
}
}
export function getDistance (start, end){
var pos = cc.v2(start.x - end.x, start.y - end.y);
var dis = Math.sqrt(pos.x*pos.x + pos.y*pos.y);
return dis;
}
export function playAudioByUrl(audio_url, cb=null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
}
}
export function btnClickAnima(btn, time=0.15, rate=1.05) {
btn.tmpScale = btn.scale;
btn.on(cc.Node.EventType.TOUCH_START, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.scale * rate})
.start()
})
btn.on(cc.Node.EventType.TOUCH_CANCEL, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.start()
})
btn.on(cc.Node.EventType.TOUCH_END, () => {
cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale})
.start()
})
}
export function getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
}
export function getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
node.addComponent(cc.Sprite).spriteFrame = sf;
return node;
}
export function getSprNodeByUrl(url, cb) {
const node = new cc.Node();
const spr = node.addComponent(cc.Sprite);
getSpriteFrimeByUrl(url, (sf) => {
spr.spriteFrame = sf;
if (cb) {
cb(spr);
}
})
}
export function playAudio(audioClip, cb = null) {
if (audioClip) {
const audioId = cc.audioEngine.playEffect(audioClip, false);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
}
}
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
try {
setTimeout(() => {
resolve(null);
}, time * 1000);
} catch (e) {
reject(e);
}
})
}
export class FireworkSettings {
baseNode; // 父节点
nodeList; // 火花节点的array
pos; // 发射点
side; // 发射方向
range; // 扩散范围
number; // 发射数量
scalseRange; // 缩放范围
constructor(baseNode, nodeList,
pos = cc.v2(0, 0),
side = cc.v2(0, 100),
range = 50,
number = 100,
scalseRange = 0
) {
this.baseNode = baseNode;
this.nodeList = nodeList;
this.pos = pos;
this.side = side;
this.range = range;
this.number = number;
this.scalseRange = scalseRange;
}
static copy(firework) {
return new FireworkSettings(
firework.baseNode,
firework.nodeList,
firework.pos,
firework.side,
firework.range,
firework.number,
);
}
}
export async function showFireworks(fireworkSettings) {
const { baseNode, nodeList, pos, side, range, number, scalseRange } = fireworkSettings;
new Array(number).fill(' ').forEach(async (_, i) => {
let rabbonNode = new cc.Node();
rabbonNode.parent = baseNode;
rabbonNode.x = pos.x;
rabbonNode.y = pos.y;
rabbonNode.angle = 60 * Math.random() - 30;
let node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
node.parent = rabbonNode;
node.active = true;
node.x = 0;
node.y = 0;
node.angle = 0;
node.scale = (Math.random() - 0.5) * scalseRange + 1;
const rate = Math.random();
const angle = Math.PI * (Math.random() * 2 - 1);
await asyncTweenBy(rabbonNode, 0.3, {
x: side.x * rate + Math.cos(angle) * range * rate,
y: side.y * rate + Math.sin(angle) * range * rate
}, {
easing: 'quadIn'
});
cc.tween(rabbonNode)
.by(8, { y: -2000 })
.start();
cc.tween(rabbonNode)
.to(5, { scale: (Math.random() - 0.5) * scalseRange + 1 })
.start();
rabbonFall(rabbonNode);
await asyncDelay(Math.random());
cc.tween(node)
.by(0.15, { x: -10, angle: -10 })
.by(0.3, { x: 20, angle: 20 })
.by(0.15, { x: -10, angle: -10 })
.union()
.repeatForever()
.start();
cc.tween(rabbonNode)
.delay(5)
.to(0.3, { opacity: 0 })
.call(() => {
node.stopAllActions();
node.active = false;
node.parent = null;
node = null;
})
.start();
});
}
async function rabbonFall(node) {
const time = 1 + Math.random();
const offsetX = RandomInt(-200, 200) * time;
await asyncTweenBy(node, time, { x: offsetX, angle: offsetX * 60 / 200 });
rabbonFall(node);
}
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
try {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve(null);
})
.start();
} catch (e) {
reject(e);
}
});
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
try {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve(null);
})
.start();
} catch (e) {
reject(e);
}
});
}
export function showTrebleFirework(baseNode, rabbonList) {
const middle = new FireworkSettings(baseNode, rabbonList);
middle.pos = cc.v2(0, -400);
middle.side = cc.v2(0, 1000);
middle.range = 200;
middle.number = 100;
middle.scalseRange = 0.4;
const left = FireworkSettings.copy(middle);
left.pos = cc.v2(-600, -400);
left.side = cc.v2(200, 1000);
const right = FireworkSettings.copy(middle);
right.pos = cc.v2(600, -400);
right.side = cc.v2(-200, 1000);
showFireworks(middle);
showFireworks(left);
showFireworks(right);
}
export function onHomeworkFinish() {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
}
} else {
console.log('onHomeworkFinish');
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"uuid": "d3ad24ed-9c8b-421d-934f-f93f1acf3060",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "24330de0-b7cd-43f1-beb7-b8067687e658",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "2ce7d58d-b6fe-4ef7-a128-de76f672a803",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "d52205af-491c-43a8-b313-07d2d8298171",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
const tools = require("../script/tools");
var onlyOne
cc.Class({
extends: cc.Component,
properties: {
quan: cc.Node,
tipsAnim: cc.Animation,
sprite: cc.Sprite,
db: dragonBones.ArmatureDisplay
},
data: null,
onLoad() {
this._playing = false
this.quan.active = false
this.tipsAnim.node.active = false
},
onEnable() {
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
},
onDisable() {
this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
},
initWithData(data, scale, xvalue, yvalue) {
this.data = data
let rect = this.data.rect
this.node.x = (rect.x + rect.width / 2) * scale + xvalue
this.node.y = (rect.y + rect.height / 2) * scale + yvalue
this.node.width = rect.width * scale
this.node.height = rect.height * scale
this.sprite.node.active = false
let comps = this.getComponentsInChildren(cc.Widget)
for (let one of comps) {
one.updateAlignment()
}
this.audioId = null
this._isComplent = false;
},
onTouchStart() {
if (g.data_mgr.nodPlayer) {
g.data_mgr.nodPlayer.onStopAudio();
}
if (this._playing) return
if (this.audioId) return
if (this.data) {
if (!this._isComplent) {
this.db.node.active = true;
this.playCatDragon();
g.game.inst.onBtnCheck();
//已经完成
this._isComplent = true;
}
if (this.data.pic_url && this.data.gIdx == 0) {
tools.getSpriteFrimeByUrl(this.data.pic_url, (sp) => {
this.sprite.spriteFrame = sp
this.sprite.node.width = this.node.width
this.sprite.node.height = this.node.height
this.sprite.node.active = true
})
}
this.quan.active = true
if (!this._playing) {
this._playing = true;
g.data_mgr.nodPlayer = this;
cc.systemEvent.once('stopMusic', this.onStopAudio, this)
// if (onlyOne != this) {
// this._playing = false
// return
// }
let url = this.data.audio_url
if (url && url != '') {
setTimeout(() => {
this.playAudio(url)
}, 500)
} else {
this._playing = false
}
}
// if (onlyOne && onlyOne != this) {
// onlyOne.hideBox()
// }
// onlyOne = this
}
},
//播放猫动画
playCatDragon() {
this.db.armatureName = "Armature";
this.db.playAnimation("newAnimation", 1);
},
onClickHide() {
this.sprite.node.active = false
this.hideBox()
},
/**隐藏边框 */
hideBox() {
this.quan.active = false
this.stopAudio()
},
/** 播放音乐 */
playAudio(url) {
cc.assetManager.loadRemote(url, (err, audioClip) => {
if (err) return
if (!this._playing) return
this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this));
this.tipsAnim.node.active = true
this.tipsAnim.play()
});
},
onStopAudio() {
this._playing = false
this.stopAudio()
},
stopAudio() {
g.data_mgr.nodPlayer = null;
this._playing = false
if (this.audioId != null) {
cc.audioEngine.stop(this.audioId)
this.audioId = null
}
this.tipsAnim.stop()
this.tipsAnim.node.active = false
cc.systemEvent.off('stopMusic', this.onStopAudio, this)
},
/** 音频id */
audioId: null,
});
{
"ver": "1.0.8",
"uuid": "f8b451ff-857c-4ca8-9870-866bc5154a29",
"uuid": "57f79280-6f4b-4d53-b1e3-1cca543a4d9e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.1.2",
"uuid": "39e69d6f-e00b-4664-9186-995a78d9238d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
const tools = require("../script/tools");
var picNode = cc.Class({
extends: cc.Component,
properties: {
hitPre: cc.Prefab,
quan: cc.Node,
},
onLoad() {
},
ctor: function () {
picNode.inst = this;
g.picNode = picNode;
},
onEnable() {
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
},
onDisable() {
this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
},
onTouchStart() {
if (g.data_mgr.nodPlayer) {
g.data_mgr.nodPlayer.onStopAudio();
}
g.speaker.inst.playEffect(g.enum.E_Audio.Error);
},
onShow(data) {
this._hitItem = []
this._sprite = this.getComponentInChildren(cc.Sprite)
this._items = this.quan;
this.initWithData(data);
},
initWithData(data) {
this.clearItems()
tools.getSpriteFrimeByUrl(data.bgItem.url, (sp) => {
//设置图片
this._sprite.spriteFrame = sp
this.photoScare(this._sprite.node);
this._items.width = this.node.width
this._items.height = this.node.height
this._items.x = -this.node.width / 2
this._items.y = this.node.height / 2
if (this._items.height / data.bgItem.rect.height < this._items.width / data.bgItem.rect.width) {
var scale = this.node.height / data.bgItem.rect.height
//X不够补X偏移量
var Xvalue = (this.node.width - data.bgItem.rect.width * scale) / 2
var Yvalue = 0;
} else {
var scale = this.node.width / data.bgItem.rect.width
//Y不够补Y偏移量
var Xvalue = 0;
var Yvalue = (this.node.height - data.bgItem.rect.height * scale) / 2
}
//初始化点击区域
let node, comp
for (let data of data.hotZoneItemArr) {
node = cc.instantiate(this.hitPre)
comp = node.getComponent('hitItem')
comp.initWithData(data, scale, Xvalue, Yvalue);
this._items.addChild(node)
this._hitItem.push(node)
}
})
},
//图片适配
photoScare: function (node) {
var height = 580;
var width = 1012;
// var maxNum = type == 0 ? 50 : 280;
let maxSize = Math.min(height / node.height, width / node.width);
if (node.perScale == undefined) {
node.perScale = node.scaleX;
} else {
node.scaleX = node.perScale;
node.scaleY = node.perScale;
}
node.scaleX *= maxSize;
node.scaleY *= maxSize;
this.maxSize = maxSize;
},
/** 清除item */
clearItems() {
this._items.removeAllChildren(true)
this._hitItem.length = 0
}
});
{
"ver": "1.0.8",
"uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5",
"uuid": "62989d72-21cb-4b26-a323-fce556c9e3c4",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
const tools = {
getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
}
}
module.exports = tools
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "ade7af40-d56d-4087-bbc6-2888fef55353",
"uuid": "68947d90-e044-48ff-8bce-670db8633681",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.1.2",
"uuid": "e1f95314-d217-4a8a-9baf-245d0533c9a8",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "e11a7c61-701d-41bd-b74b-dbac7efd3a7e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 366,
"height": 336,
"width": 351,
"height": 93,
"platformSettings": {},
"subMetas": {
"1orange": {
"bg_bottom": {
"ver": "1.0.4",
"uuid": "43d1e79d-6de8-4dcb-b8ce-d767df7913aa",
"rawTextureUuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "c260e7d3-9aa7-46ca-99f5-7ca5f31f7fef",
"rawTextureUuid": "e11a7c61-701d-41bd-b74b-dbac7efd3a7e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"offsetY": 0,
"trimX": 0,
"trimY": 1,
"width": 366,
"height": 335,
"rawWidth": 366,
"rawHeight": 336,
"trimY": 0,
"width": 351,
"height": 93,
"rawWidth": 351,
"rawHeight": 93,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "82ae3bc3-8bdf-463b-97d1-60ebd190bad2",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 170,
"height": 100,
"platformSettings": {},
"subMetas": {
"bg_quan": {
"ver": "1.0.4",
"uuid": "9b336882-962e-447b-9d2c-89aca2bf95b4",
"rawTextureUuid": "82ae3bc3-8bdf-463b-97d1-60ebd190bad2",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 170,
"height": 100,
"rawWidth": 170,
"rawHeight": 100,
"borderTop": 31,
"borderBottom": 31,
"borderLeft": 31,
"borderRight": 31,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "617acbce-eb22-416b-b5d5-f1eaf7187ca9",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 34,
"height": 34,
"platformSettings": {},
"subMetas": {
"btn_x": {
"ver": "1.0.4",
"uuid": "b7316664-aba4-4008-a54a-11908a6c0b15",
"rawTextureUuid": "617acbce-eb22-416b-b5d5-f1eaf7187ca9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 34,
"height": 34,
"rawWidth": 34,
"rawHeight": 34,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "eacc8e5b-ced0-41c7-a1de-70fb0645bf60",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 49,
"height": 49,
"platformSettings": {},
"subMetas": {
"icon_dian": {
"ver": "1.0.4",
"uuid": "5daba96f-eff5-4bee-9ba9-d67c0134212a",
"rawTextureUuid": "eacc8e5b-ced0-41c7-a1de-70fb0645bf60",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 49,
"height": 49,
"rawWidth": 49,
"rawHeight": 49,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ed5b81e2-ee7b-4f76-b424-9df340e5f298",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 69,
"height": 78,
"platformSettings": {},
"subMetas": {
"icon_hand": {
"ver": "1.0.4",
"uuid": "562deefd-c9fd-42f0-97d7-d6f5893ef3f3",
"rawTextureUuid": "ed5b81e2-ee7b-4f76-b424-9df340e5f298",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 69,
"height": 78,
"rawWidth": 69,
"rawHeight": 78,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"uuid": "1d277eb9-4061-4e88-9905-dfc6cf68a672",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 144,
"height": 144,
"width": 69,
"height": 78,
"platformSettings": {},
"subMetas": {
"icon": {
"icon_hand2": {
"ver": "1.0.4",
"uuid": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a",
"rawTextureUuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"uuid": "61e47c68-658d-416b-a46e-399ebfddd2c8",
"rawTextureUuid": "1d277eb9-4061-4e88-9905-dfc6cf68a672",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 3,
"offsetY": -1,
"trimX": 0,
"trimY": 2,
"width": 138,
"height": 141,
"rawWidth": 144,
"rawHeight": 144,
"width": 69,
"height": 76,
"rawWidth": 69,
"rawHeight": 78,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "b3254bf5-7afe-4d42-8815-9693edf14d81",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"width": 46,
"height": 67,
"platformSettings": {},
"subMetas": {
"btn_left": {
"icon_tips": {
"ver": "1.0.4",
"uuid": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5",
"rawTextureUuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "b41667f5-0e09-49f6-b7e8-19b88dc8ea8b",
"rawTextureUuid": "b3254bf5-7afe-4d42-8815-9693edf14d81",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,9 +22,9 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 61,
"width": 46,
"height": 67,
"rawWidth": 61,
"rawWidth": 46,
"rawHeight": 67,
"borderTop": 0,
"borderBottom": 0,
......
{
"__type__": "cc.AnimationClip",
"_name": "tips",
"_objFlags": 0,
"_native": "",
"_duration": 0.5,
"sample": 40,
"speed": 1,
"wrapMode": 2,
"curveData": {
"props": {
"opacity": [
{
"frame": 0,
"value": 255,
"curve": "cubicIn"
},
{
"frame": 0.25,
"value": 0,
"curve": "cubicIn"
},
{
"frame": 0.5,
"value": 255
}
]
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "a6b7da30-d79b-4854-9182-3c973cef9e5e",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "e5510638-fc47-4bba-a7ed-e8b70cd74cd4",
"downloadMode": 0,
"duration": 1.776327,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b",
"uuid": "1e632c07-6c31-404b-8a45-ff1f55c236eb",
"downloadMode": 0,
"duration": 0.130612,
"subMetas": {}
......
{
"ver": "2.0.1",
"uuid": "5fc68702-8884-47b7-a1f4-e4c3e05053cb",
"downloadMode": 0,
"duration": 4.04898,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "7e550adf-98ad-4a4e-a238-725aca313c49",
"downloadMode": 0,
"duration": 0.470204,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "de5a7da8-a6b4-414b-9143-2f00b90d4d7e",
"downloadMode": 0,
"duration": 0.264,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "721842df-3ed0-4638-9601-884f3c385865",
"downloadMode": 0,
"duration": 2.115917,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "5317ff9d-23a3-4bb2-bba8-53b5321b553b",
"subMetas": {}
}
\ No newline at end of file
{"name":"right","imagePath":"right_tex.png","SubTexture":[{"name":"1/圆","x":1,"height":98,"y":1,"width":98},{"name":"1/星1","x":66,"height":59,"y":172,"width":57},{"name":"1/星2","x":71,"height":45,"y":101,"width":43},{"name":"1/星3","x":1,"height":64,"y":172,"width":63},{"name":"1/星4","x":183,"height":45,"y":172,"width":45},{"name":"1/星6","x":1,"height":69,"y":101,"width":68},{"name":"1/星7","x":116,"height":40,"y":101,"width":37},{"name":"1/星5","x":125,"height":57,"y":172,"width":56},{"name":"1/星8","x":183,"height":33,"y":219,"width":32},{"name":"1/星9","x":155,"height":37,"y":101,"width":36}],"height":256,"width":256}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "ae34c776-2b35-437c-92f2-9c87edd10dcb",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ec38e850-44bb-4052-9453-bb4c65bb0afe",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 256,
"height": 256,
"platformSettings": {},
"subMetas": {
"right_tex": {
"ver": "1.0.4",
"uuid": "204b1483-d215-4577-bd52-56d30e0ae17c",
"rawTextureUuid": "ec38e850-44bb-4052-9453-bb4c65bb0afe",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -13.5,
"offsetY": 1.5,
"trimX": 1,
"trimY": 1,
"width": 227,
"height": 251,
"rawWidth": 256,
"rawHeight": 256,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "bf718d00-23b5-4393-8285-ef7a241b9afa",
"subMetas": {}
}
\ No newline at end of file
{"name":"正确效果","SubTexture":[{"name":"1/勾","x":1,"height":112,"y":1,"width":128},{"name":"1/星1","x":196,"height":59,"y":72,"width":57},{"name":"1/星2","x":1,"height":45,"y":192,"width":43},{"name":"1/星3","x":131,"height":64,"y":72,"width":63},{"name":"1/星4","x":201,"height":45,"y":1,"width":45},{"name":"1/星6","x":131,"height":69,"y":1,"width":68},{"name":"1/星7","x":1,"height":40,"y":115,"width":37},{"name":"1/星5","x":196,"height":57,"y":133,"width":56},{"name":"1/星8","x":78,"height":33,"y":115,"width":32},{"name":"1/星9","x":40,"height":37,"y":115,"width":36}],"imagePath":"正确效果_tex.png","height":256,"width":256}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "2a1c4975-20c7-425f-a159-537a0e44fbcb",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ff0f9fe1-277f-4d06-9a86-2b838f49e899",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 256,
"height": 256,
"platformSettings": {},
"subMetas": {
"正确效果_tex": {
"ver": "1.0.4",
"uuid": "ef344e8b-5ff7-495c-8441-7891c9963a6f",
"rawTextureUuid": "ff0f9fe1-277f-4d06-9a86-2b838f49e899",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1,
"offsetY": 9,
"trimX": 1,
"trimY": 1,
"width": 252,
"height": 236,
"rawWidth": 256,
"rawHeight": 256,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "455577d8-9fe9-451b-8bb0-241ffe3d08ef",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "2.1.0",
"uuid": "ac5cd74f-7311-4fae-a586-f37a87e61455",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "2.1.0",
"uuid": "ce2d6cce-f4b4-4f14-b57c-f026dc181a88",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "da124b99-7f04-47cd-942e-a9f80f0b4f04",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "61fcc759-2eb5-4e50-a2f3-0cc3393881d8",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "4fe6019f-f84c-439f-97b8-a4cfe2ddc7ca",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "f0214b38-1b2a-41ef-aa3e-1d6949fd3b12",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "1fc51dd0-d295-4a33-8b99-adcb5978c932",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "5c0041d0-ccbd-4069-bc12-73a47695ed52",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "a777fdf7-eb0b-41df-b0f7-ada8ed99b97d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "c020c4aa-c261-4e24-ae6e-a564a5bb6865",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "8b78aa33-0eb9-4b52-ae1b-3abacd0ee4f2",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"uuid": "14c37636-02d3-4ff8-8d46-32898ddb9a11",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
......
/**
* 游戏主逻辑
*/
var game = cc.Class({
extends: cc.Component,
properties: {
btnRestart: {
default: null,
type: cc.Node,
displayName: "重开按钮"
}
},
ctor: function () {
game.inst = this;
g.game = game;
},
// 生命周期 onLoad
onLoad() {
//初始化游戏
this.initGame();
if (window.addEventListener) {
window.addEventListener('resize', this.scaleEventCallBack, false)
} else if (window.attachEvent) {
window.attachEvent('resize', this.scaleEventCallBack, false)
}
cc.debug.setDisplayStats(false);
},
//屏幕缩放
scaleEventCallBack: function () {
g.event_mgr.send("adjustUI");
},
//初始化游戏
initGame: function () {
//获得数据
g.res_mgr.getFormData();
},
onBtnTest() {
g.Light.inst.addLightNum(3);
},
onBtnTest2() {
g.Light.inst.showLight();
},
//检查当前缩放倍数
checkScale: function (num) {
var scale = 1;
if (num > 2 && num <= 4) {
scale = 0.74
}
if (num > 4) {
scale = 0.65
}
return scale;
},
//添加节点
addItem: function () {
let itemArr = g.data_mgr.getSheepArr();
this.idx = this.checkNodeParent();
g.data_mgr.nowNum = itemArr.length;
itemArr.sort(function () { return Math.random() > 0.5 ? -1 : 1; })
for (var i = 0; i < itemArr.length; i++) {
let newItem_0 = cc.instantiate(this.Item_0[itemArr.length > 14 ? 0 : 1]);
//更新子项
var com = newItem_0.getChildByName("item").getComponent("item");
let itemInfo = itemArr[i];
com.updateUI(itemInfo);
newItem_0.active = true;
//设置类别
let sheepInfo = g.data_mgr.getSheep(i);
newItem_0.getChildByName("item").type = this.checkType(sheepInfo.sheepfoldId);
newItem_0.parent = this.contentArr_2[this.idx];
};
},
//检测放到哪个节点底下
checkNodeParent: function () {
//获取到总列表
var itemArr = g.data_mgr.getSheepArr();
//
if (itemArr.length <= 7) {
this.contentArr_2[1].active = true;
var idx = 1;
} else {
this.contentArr_2[0].active = true;
var idx = 0;
}
return idx;
},
//检查类别
checkType: function (Id) {
for (var i in g.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i];
if (Id == sheepfoldInfo.id) {
return ~~i + 1;
}
}
return -1;
},
//设置目标节点类型
setOptionType: function () {
//设置类型
this.OptionType = g.data_mgr.getSheepfoldArr().length - 3;
},
getOptionType: function () {
return this.OptionType;
},
//更新界面信息
UpdataUi: function () {
this.btnRestart.active = false;
//设置题目长度
g.scoreStart.inst.addStar(g.data_mgr.data.starArr.length);
g.data_mgr.ansId = 0;
g.data_mgr.startId = 0;
//初始化单题题目
this.InitQuestion();
},
//初始化单个题目
InitQuestion() {
var question = g.data_mgr.data.starArr[g.data_mgr.startId].queArr[g.data_mgr.ansId]
//初始化灯
g.Light.inst.addLightNum(question.hotZoneItemArr.length);
//初始化标题
g.titleType.inst.showTitle(question.title, question.title_audio_url);
if (question.title_audio_url) {
g.data_mgr.gameState = 2;
setTimeout(() => {
g.titleType.inst.onBtnPlayEffect();
}, 500)
}
//设置中间图片
g.picNode.inst.onShow(question);
},
onBtnCheck() {
//默认答对
//播放特效
//灯+1
g.speaker.inst.playEffect(g.enum.E_Audio.Right);
let num = g.Light.inst.showLight();
if (num == -1) {
g.data_mgr.ansId += 1;
if (g.data_mgr.ansId >= g.data_mgr.data.starArr[g.data_mgr.startId].queArr.length) {
//大星星音效
g.speaker.inst.playEffect(g.enum.E_Audio.Star);
g.scoreStart.inst.showStar();
g.data_mgr.ansId = 0;
g.data_mgr.startId += 1;
}
setTimeout(() => {
if (g.data_mgr.startId >= g.data_mgr.data.starArr.length) {
g.speaker.inst.playEffect(g.enum.E_Audio.Flowers);
g.effect.inst.showEffect2();
this.btnRestart.active = true;
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
}
} else {
console.log('onHomeworkFinish');
}
} else {
this.InitQuestion();
}
}, 1500)
}
},
//播放标题音效
playAudioTitle: function () {
//获得播放路径
var path = g.data_mgr.data.audio_url;
g.res_mgr.playAudioByUrl(path, (url) => {
g.snd_mgr.playEffect(url, null);
});
},
//重置UI界面
resetUI: function () {
//移除所有子节点
this.contentArr_2[0].removeAllChildren();
this.contentArr_2[1].removeAllChildren();
//移除所有子节点
g.event_mgr.send("reSetGame");
},
//重新开始
onBtnReStart: function () {
g.speaker.inst.playEffect(g.enum.E_Audio.BtnCommom);
//移除所有计时器
this.unscheduleAllCallbacks();
//初始化界面
this.UpdataUi();
},
//游戏开始
gameStart: function () {
console.log("游戏开始:" + g.data_mgr);
//播放一个上面的音乐
this.setAudioInfo(1);
},
checkAnswer(caller, option_i) {
if (caller == undefined) {
return;
}
if (option_i != -1) {
let nodOption = this.contType[this.OptionType].children[option_i - 1]
if (nodOption) {
let AABB = nodOption.getComponent("DragGameOptionObject").setAABB();
let callerAABB = this.getCallerAABB(caller);
var isIntersect = AABB.containsRect(callerAABB);//判断是否被包含
console.log(isIntersect)
if (isIntersect) {
return nodOption;
}
return false
}
}
},
getCallerAABB(caller) {
let svLeftBottomPoint = caller.parent.convertToWorldSpaceAR(
cc.v2(
caller.x,
caller.y
)
);
var posNode_1 = cc.rect(
svLeftBottomPoint.x,
svLeftBottomPoint.y,
0,
0
);
return posNode_1
},
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment