"use strict"; cc._RF.push(module, 'd63eeqXqS5GV5T/inM6K0aA', 'Block'); // Script/Block.ts "use strict"; // 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 var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); //出现块的类型,问题以及答案 var BlockType = cc.Enum({ problem_In: 1, problem_Out: 2, correct_In: 3, correct_Out: 4, err_In: 5, err_Out: 6, }); var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; var Block = /** @class */ (function (_super) { __extends(Block, _super); function Block() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.UI = null; return _this; // update (dt) { // } } // LIFE-CYCLE CALLBACKS: Block.prototype.onLoad = function () { // this.init(); this.GameManager = this.node.parent.parent.parent.getComponent("GameManager"); this._touch = false; this._start = false; this._answer = false; this._inside = true; this.node.on(cc.Node.EventType.TOUCH_START, this.touchStart, this); }; Block.prototype.init = function (type, id) { if (type == BlockType.correct_Out) { } }; Block.prototype.setId = function (id) { this._idNumber = id; }; Block.prototype.answerShow = function (texture) { var _this = this; this.node.getChildByName("texture").active = true; var textureName = "texture" + texture; // @ts-ignore this.node.getChildByName("texture").getComponent(cc.Sprite).spriteFrame = this.UI._spriteFrames[textureName]; cc.tween(this.node.getChildByName("texture")) .to(0.01, { opacity: 255 }) .delay(this.GameManager.config["showTime"] - 0.05) .call(function () { if (_this._inside) { _this.node.getChildByName("texture").opacity = 0; } }) .start(); }; Block.prototype.lockShow = function (type, inside) { this.node.getChildByName("texture").active = false; this._answer = type; this._inside = inside; this.node.getChildByName("lock").active = true; this._touch = true; }; Block.prototype.lockHide = function () { this.node.getChildByName("lock").active = false; this._touch = false; }; Block.prototype.show = function (type, inside, texture) { var _this = this; // this._answer = type; this._inside = inside; if (inside) this._answer = type; var textureName = "texture" + texture; this.node.getChildByName("texture").active = true; //正确答案 //@ts-ignore this.node.getChildByName("texture").getComponent(cc.Sprite).spriteFrame = this.UI._spriteFrames[textureName]; cc.tween(this.node.getChildByName("texture")) .to(0.01, { opacity: 255 }) // .delay(this.GameManager.config["showTime"]-0.1) .call(function () { if (inside) { _this._touch = true; } }) .start(); }; Block.prototype.set_Pos = function () { this._start = true; }; Block.prototype.set_Touch = function (type) { this._touch = type; }; Block.prototype.start = function () { }; //开始点击,提高层级 Block.prototype.touchStart = function (event) { if (this._touch) { if (this._answer) { this.node.getChildByName("yes").active = true; var data = { "result": true, "type": this._inside, id: this._idNumber }; cc.fx.Notifications.emit("result", data); } else { this.node.getChildByName("err").active = true; var data = { "result": false, "type": this._inside, id: this._idNumber }; cc.fx.Notifications.emit("result", data); } } }; __decorate([ property(cc.Asset) ], Block.prototype, "UI", void 0); Block = __decorate([ ccclass ], Block); return Block; }(cc.Component)); exports.default = Block; cc._RF.pop();