Jquery 更新功能不支持';在移相器中不在文件中工作
我有一个这样结构的游戏(删除了一些代码行,但Browserify需要所有文件): 游戏需要boot.js和play.js game.js:Jquery 更新功能不支持';在移相器中不在文件中工作,jquery,node.js,browserify,phaser-framework,Jquery,Node.js,Browserify,Phaser Framework,我有一个这样结构的游戏(删除了一些代码行,但Browserify需要所有文件): 游戏需要boot.js和play.js game.js: w = window.innerWidth * window.devicePixelRatio, h = window.innerHeight * window.devicePixelRatio; window.game = new Phaser.Game((h > w) ? h : w, (h > w) ? w : h, Phaser.CAN
w = window.innerWidth * window.devicePixelRatio,
h = window.innerHeight * window.devicePixelRatio;
window.game = new Phaser.Game((h > w) ? h : w, (h > w) ? w : h, Phaser.CANVAS, 'Phaser', {render:render});
game.state.add('Boot', require('./states/boot.js'));
game.state.add('Play', require('./states/play.js'));
boot.js启动play.js 在boot.js中:
module.exports = {
preload: function() {
//...
},
create: function() {
game.physics.startSystem(Phaser.Physics.ARCADE);
game.world.setBounds(0, 0, 6000, 6000);
this.game.state.start("Play");
}
};
play.js需要interfacePanels.js 在play.js中:
chat = require('./../chat.js');
interfacePanels = require('./../interfacePanels.js');
module.exports = {
create: function() {
interfacePanels.init();
},
update: function() {
//....
}
};
有一种方法可以在interfacePanels.js中显示播放器的配置文件(该文件需要profile.js) 代码如下:
profile = require('./profile.js');
module.exports = {
show: function(buttonType) {
switch(buttonType.key) {
case 'menuButtonPress':
break;
case 'profileButtonPress':
if(profile.initialized == false) {
profile.create();
profile.initialized = true;
}
break;
}
}
}
profile.js中存在问题:
module.exports = {
initialized: false,
START_X: '',
START_Y: '',
create: function() {
//... some code
},
update: function() {
console.log('profile')
},
};
更新功能根本不起作用
我可以尝试添加更新功能来play.js文件,但是如果我这样做的话,会有很多if console.log命令吗
我需要这个来将元素移动到起始点,并检查它们是否重叠。这非常有趣。谢谢@drhayes
// In play.js...
var profile = require('./profile');
module.exports = {
// other state functions...
update: function() {
profile.update();
}
};
这些功能中有任何一个可以工作吗?资产是否已加载?
create
get call吗?@PhotonStorm,当然。所有功能都运行良好。“创建”被调用。但是“更新”根本不会被调用。@PhotonStorm、Browserify和Phaser在这里一起工作。您共享的几件事情似乎还可以,您可能减少了太多代码,我们无法提供帮助。例如,我们看不到“profile”模块是如何在所有位置导入/使用的。如果调用了其他函数,那么这是我们在代码中看不到的。我的猜测是,某个地方的另一个函数正在覆盖更新,因此您没有看到日志。