cocos creater2.0 打飞机练习
立即下载
资源介绍:
cocos creater2.0 打飞机练习 typescript
(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/script/player.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, 'babb4w2d6BMDrqViu3ztZdM', 'player', __filename);
// script/player.ts
// Learn TypeScript:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Player = /** @class */ (function (_super) {
__extends(Player, _super);
function Player() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.label = null;
_this.text = 'hello';
_this.bullet = null;
return _this;
}
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
Player.prototype.start = function () {
var _this = this;
var self = this;
this.node.on(cc.Node.EventType.TOUCH_MOVE, function (event) {
self.node.setPosition(event.getLocation());
});
this.schedule(function () {
var bulleto = cc.instantiate(_this.bullet);
bulleto.setParent(cc.director.getScene());
bulleto.x = _this.node.x;
bulleto.y = _this.node.y + _this.node.height / 2 + 2;
}, 0.5); //定时器
cc.director.getCollisionManager().enabled = true;
};
Player.prototype.update = function (dt) {
//
};
Player.prototype.die = function () {
var _this = this;
cc.loader.loadRes("hero_die", cc.SpriteFrame, function (err, res) {
if (err) {
console.log(err);
return;
}
_this.getComponent(cc.Sprite).spriteFrame = res;
});
setTimeout(function () {
_this.node.destroy();
}, 300);
};
__decorate([
property(cc.Label)
], Player.prototype, "label", void 0);
__decorate([
property
], Player.prototype, "text", void 0);
__decorate([
property(cc.Prefab)
], Player.prototype, "bullet", void 0);
Player = __decorate([
ccclass
], Player);
return Player;
}(cc.Component));
exports.default = Player;
cc._RF.pop();
}
if (CC_EDITOR) {
__define(__module.exports, __require, __module);
}
else {
cc.registerModuleFunc(__filename, function () {
__define(__module.exports, __require, __module);
});
}
})();
//# sourceMappingURL=player.js.map
资源文件列表:
hitPlane.zip 大约有273个文件