生成出来的project.dev.js文件内容
window.__require = function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
var b = o.split("/");
b = b[b.length - 1];
if (!t[b]) {
var a = "function" == typeof __require && __require;
if (!u && a) return a(b, !0);
if (i) return i(b, !0);
throw new Error("Cannot find module '" + o + "'");
}
}
var f = n[o] = {
exports: {}
};
t[o][0].call(f.exports, function(e) {
var n = t[o][1][e];
return s(n || e);
}, f, f.exports, e, t, n, r);
}
return n[o].exports;
}
var i = "function" == typeof __require && __require;
for (var o = 0; o < r.length; o++) s(r[o]);
return s;
}({
backManager: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "edac8J2Zr5LWLEenmU4lNnA", "backManager");
"use strict";
cc.Class({
extends: cc.Component,
properties: {},
ctor: function ctor() {
this._node_bg_1 = void 0;
this._node_bg_2 = void 0;
},
init: function init(parent) {
cc.loader.loadRes("images/img_bg", cc.SpriteFrame, function(err, spriteFrame) {
if (err) {
console.log("---------cc.loader.loadRes---------", err);
return;
}
this._node_bg_1 = new cc.Node();
var sprite_1 = this._node_bg_1.addComponent(cc.Sprite);
sprite_1.spriteFrame = spriteFrame;
this._node_bg_1.zIndex = -1;
parent.addChild(this._node_bg_1);
this._node_bg_2 = new cc.Node();
var sprite_2 = this._node_bg_2.addComponent(cc.Sprite);
sprite_2.spriteFrame = spriteFrame;
this._node_bg_2.zIndex = -1;
this._node_bg_2.y = this._node_bg_1.getContentSize().height;
parent.addChild(this._node_bg_2);
}.bind(this));
},
update: function update(dt) {
if (!this._node_bg_1 || !this._node_bg_2) return;
this._node_bg_1.y -= 100 * dt;
this._node_bg_2.y -= 100 * dt;
var height = this._node_bg_1.getContentSize().height;
this._node_bg_1.y = this._node_bg_1.y <= -height ? this._node_bg_2.y + height : this._node_bg_1.y;
this._node_bg_2.y = this._node_bg_2.y <= -height ? this._node_bg_1.y + height : this._node_bg_2.y;
}
});
cc._RF.pop();
}, {} ],
bulletManager: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "3ede6VT+CVO/7tmJCChz1kX", "bulletManager");
"use strict";
cc.Class({
extends: cc.Component,
properties: {},
ctor: function ctor() {
this._bulletPoll = void 0;
this._prefab = void 0;
this._owner = void 0;
},
init: function init(owner) {
this._bulletPoll = new cc.NodePool();
this._owner = owner;
this._prefab = owner.bulletPrefab;
for (var i = 0; i < window.bullet_pool_size; ++i) {
var bullet = cc.instantiate(this._prefab);
this._bulletPoll.put(bullet);
}
},
clear: function clear() {
this._bulletPoll.clear();
},
create: function create() {
var bullet = this._bulletPoll.get();
bullet || (bullet = cc.instantiate(this._prefab));
if (bullet) {
var script = bullet.getComponent("bullet");
script && script.init(this._owner) && cc.director.getScene().getChildByName("Canvas").addChild(bullet);
}
},
recovery: function recovery(object) {
this._bulletPoll.put(object);
}
});
cc._RF.pop();
}, {} ],
bullet: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "fb8523veopCgIVB5yhwZMQF", "bullet");
"use strict";
cc.Class({
extends: cc.Component,
properties: {},
ctor: function ctor() {
this._owner = void 0;
},
start: function start() {},
init: function init(owner) {
if (!owner) return false;
this._owner = owner;
var owner_node = this._owner.getNode();
if (!owner_node) return false;
this.node.setPosition(owner_node);
this.node.active = true;
return true;
},
update: function update(dt) {
this.node.y += 1e3 * dt;
if (this.node.y > cc.view.getVisibleSize().height / 2) {
var bulletManager = this._owner.getBulletManager();
bulletManager && bulletManager.recovery(this.node);
}
}
});
cc._RF.pop();
}, {} ],
define: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "30c51TODVNP3Ig7qtr7XPGg", "define");
"use strict";
window.enemy_pool_size = 100;
window.bullet_pool_size = 500;
cc._RF.pop();
}, {} ],
enemyManager: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "798e0nmLo1I2J7/rmXB4nAl", "enemyManager");
"use strict";
cc.Class({
extends: cc.Component,
properties: {},
ctor: function ctor() {
this._enemyPoll = void 0;
this._prefab = void 0;
this._owner = void 0;
},
init: function init(owner) {
this._enemyPoll = new cc.NodePool();
this._owner = owner;
this._prefab = owner.enemyPrefab;
for (var i = 0; i < window.enemy_pool_size; ++i) {
var enemy = cc.instantiate(this._prefab);
this._enemyPoll.put(enemy);
}
},
clear: function clear() {
this._enemyPoll.clear();
},
create: function create() {
var enemy = this._enemyPoll.get();
enemy || (enemy = cc.instantiate(this._prefab));
if (enemy) {
var script = enemy.getComponent("enemy");
script && script.init(this._owner) && cc.director.getScene().getChildByName("Canvas").addChild(enemy);
}
},
recovery: function recovery(object) {
this._enemyPoll.put(object);
}
});
cc._RF.pop();
}, {} ],
enemy: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "e0cachA2EpNV5UQ7fk2MVc1", "enemy");
"use strict";
cc.Class({
extends: cc.Component,
properties: {},
init: function init(owner) {
if (!owner) return false;
this._owner = owner;
var size = cc.view.getVisibleSize();
var min_x = -size.width / 2 + this.node.getContentSize().width / 2;
var max_x = size.width / 2 - this.node.getContentSize().width / 2;
var posx = (Math.random() - .5) * size.width;
posx = posx < min_x ? min_x : posx;
posx = posx > max_x ? max_x : posx;
this.node.setPosition(posx, size.height / 2);
this.node.active = true;
return true;
},
onCollisionEnter: function onCollisionEnter(other, self) {
var script = self.getComponent("enemy");
script && script.handleDie();
},
handleDie: function handleDie() {
this.node.destroy();
},
update: function update(dt) {
this.node.y -= 200 * dt;
this.node.y < -cc.view.getVisibleSize().height / 2 && this.node.destroy();
}
});
cc._RF.pop();
}, {} ],
gameManager: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "52039UVynZJRbif1z4eGZFU", "gameManager");
"use strict";
var enemyManager = require("Manager/enemyManager");
var backManager = require("Manager/backManager");
cc.Class({
extends: cc.Component,
properties: {
enemyPrefab: {
default: null,
type: cc.Prefab
}
},
ctor: function ctor() {
this._timer = 0;
this._interval = 2;
this._enemyManager = void 0;
this._backManager = void 0;
this._collisionManager = void 0;
},
onLoad: function onLoad() {
this._enemyManager = new enemyManager();
this._enemyManager.init(this);
this._backManager = new backManager();
this._backManager.init(this.node);
this._collisionManager = cc.director.getCollisionManager();
this._collisionManager.enabled = true;
this._collisionManager.enabledDebugDraw = true;
},
onDestroy: function onDestroy() {
this._collisionManager.enabled = false;
this._collisionManager.enabledDebugDraw = false;
},
update: function update(dt) {
this._backManager.update(dt);
this._timer += dt;
if (this._timer < this._interval) return;
this._enemyManager.create();
this._timer = 0;
}
});
cc._RF.pop();
}, {
"Manager/backManager": void 0,
"Manager/enemyManager": void 0
} ],
loading: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "446e648nUBE46wplcIWW/jy", "loading");
"use strict";
cc.Class({
extends: cc.Component,
properties: {},
ctor: function ctor() {
this._processBar = void 0;
this._btnEnter = void 0;
},
onLoad: function onLoad() {
this._btnEnter = this.node.getChildByName("btnEnter");
this._processBar = this.node.getChildByName("progressBar");
this._btnEnter.active = false;
cc.director.preloadScene("fly_scene");
},
start: function start() {},
update: function update(dt) {
var component_bar = this._processBar.getComponent(cc.ProgressBar);
if (component_bar.progress < 1) component_bar.progress += .5 * dt; else {
this._processBar.active = false;
this._btnEnter.active = true;
}
},
callback: function callback(event, customEventData) {
cc.director.loadScene("fly_scene");
}
});
cc._RF.pop();
}, {} ],
player: [ function(require, module, exports) {
"use strict";
cc._RF.push(module, "bb2f65SFUBDh7+8Ilar9oSc", "player");
"use strict";
var bulletManager = require("Manager/bulletManager");
cc.Class({
extends: cc.Component,
properties: {
bulletPrefab: {
default: null,
type: cc.Prefab
}
},
ctor: function ctor() {
this._timer = 0;
this._interval = .5;
this._bulletManager = void 0;
},
onLoad: function onLoad() {
var _this = this;
this._bulletManager = new bulletManager();
this._bulletManager.init(this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, function(event) {
var delta = event.getDelta();
_this.node.setPosition(_this.node.x + delta.x, _this.node.y + delta.y);
}, this);
},
onDestroy: function onDestroy() {
this._bulletManager.clear();
},
getBulletManager: function getBulletManager() {
return this._bulletManager;
},
getNode: function getNode() {
return this.node;
},
update: function update(dt) {
this._timer += dt;
if (this._timer < this._interval) return;
this._bulletManager.create();
this._timer = 0;
}
});
cc._RF.pop();
}, {
"Manager/bulletManager": void 0
} ]
}, {}, [ "backManager", "bulletManager", "enemyManager", "define", "bullet", "enemy", "player", "gameManager", "loading" ]);
在第17行会报错
VM6975:1 gameThirdScriptError
Cannot read property '0' of undefined
TypeError: Cannot read property '0' of undefined
at s (http://127.0.0.1:42625/game/src/project.dev.js:17:11)
at http://127.0.0.1:42625/game/src/project.dev.js:19:16
at Object.window.__require.r.player.Manager/bulletManager (http://127.0.0.1:42625/game/src/project.dev.js:299:25)
at s (http://127.0.0.1:42625/game/src/project.dev.js:17:15)
at e (http://127.0.0.1:42625/game/src/project.dev.js:25:38)
at http://127.0.0.1:42625/game/src/project.dev.js:27:2
at require (http://127.0.0.1:42625/game/__dev__/WAGame.js:1:78970)
at http://127.0.0.1:42625/game/__dev__/WAGame.js:1:78579
at Downloader.downloadScript (http://127.0.0.1:42625/game/libs/engine/downloader.js:15:5)
at Downloader.117.Downloader.handle (http://127.0.0.1:42625/game/cocos2d-js.js:21424:32)
但是如果把call的那段代码注释掉,直接console.log(t[o][0])是可以打印出来的,并且是个函数。
各位大佬,求解如何解决?


