Sun_moves/library/imports/4b/4be67b1d-91ec-42ca-a2e5-d0d1ddf4dd5f.js
2024-12-10 16:11:21 +08:00

109 lines
4.6 KiB
JavaScript

"use strict";
cc._RF.push(module, '4be67sdkexCyqLl0NHd9N1f', 'Sun');
// Script/Sun.ts
"use strict";
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 _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NewClass = /** @class */ (function (_super) {
__extends(NewClass, _super);
function NewClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
// onLoad () {}
NewClass.prototype.start = function () {
this.node.on(cc.Node.EventType.TOUCH_START, this.clickBtn, this);
};
//初始化数据
NewClass.prototype.init = function (_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();
};
//用于作弊 测试
NewClass.prototype.showNumber = function (type) {
this.node.getChildByName("number").active = type;
if (type == true)
this.node.getChildByName("number").getComponent(cc.Label).string = this.id_Number + "";
};
//计算两点之间直线距离
NewClass.prototype.distanceBetweenTwoPoints = function (x1, y1, x2, y2) {
return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
};
//点击事件
NewClass.prototype.clickBtn = function (event, data) {
var pos = this.node.convertToNodeSpaceAR(event.getLocation());
var distance = this.distanceBetweenTwoPoints(pos.x, 0, pos.y, 0);
distance = Math.floor(distance * 10) / 10;
if (this.node.name != "qiu4") {
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;
var data_1 = { id: this.id_Number, distance: distance };
cc.fx.Notifications.emit("clickSun", data_1);
}
}
else {
this.touch = false;
this.node.zIndex = -1;
var data_2 = { id: this.id_Number, distance: distance };
cc.fx.Notifications.emit("clickSun", data_2);
}
}
}
else {
if (this.touch == true && this.node.parent.parent.getComponent("GuideManager").begin == true) {
this.touch = false;
this.node.zIndex = -1;
var data_3 = { id: this.id_Number, distance: distance };
cc.fx.Notifications.emit("clickSun", data_3);
}
}
};
NewClass = __decorate([
ccclass
], NewClass);
return NewClass;
}(cc.Component));
exports.default = NewClass;
cc._RF.pop();