weratius Posted May 7, 2015 Share Posted May 7, 2015 I have a game with structure like this.(Some lines of code were deleted. Also all file are required by Browserify)Game needs boot.js and play.jsgame.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.CANVAS, 'Phaser', {render:render});game.state.add('Boot', require('./states/boot.js'));game.state.add('Play', require('./states/play.js')); boot.js starts play.jsIn 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 requires interfacePanels.jsIn play.js:chat = require('./../chat.js');interfacePanels = require('./../interfacePanels.js');module.exports = { create: function() { interfacePanels.init(); }, update: function() { //.... }};There is a method that shows profile of a player in interfacePanels.js (also this file requires profile.js) And here is the problem file profile.js:module.exports = { initialized: false, START_X: '', START_Y: '', create: function() { //... some code }, update: function() { console.log('profile') },};And so, update function doesn't work at allI wonder but if I add update function in play.js file there will be a lot if console.log commandsPlease, I need help)I need this to move elements to starts points and check whether overLap happens or notThank you in advance!!! Link to comment Share on other sites More sharing options...
drhayes Posted May 7, 2015 Share Posted May 7, 2015 Why should profile.js' update method get called every frame? If your play.js state isn't calling anything in interfacePanels in its update method, and interfacePanels doesn't then call profile.js... then that's probably why it's broken. Link to comment Share on other sites More sharing options...
weratius Posted May 7, 2015 Author Share Posted May 7, 2015 Why should profile.js' update method get called every frame? If your play.js state isn't calling anything in interfacePanels in its update method, and interfacePanels doesn't then call profile.js... then that's probably why it's broken.But why just I can't call update method in profile.js ? I need this due to the variables I have there. It will be easier and etc. Is it possible? Link to comment Share on other sites More sharing options...
drhayes Posted May 7, 2015 Share Posted May 7, 2015 Again, I'm not seeing enough code here. Sure, you could do this:// In play.js...var profile = require('./profile');module.exports = { // other state functions... update: function() { profile.update(); }};In your code examples, nothing in play.js is calling anything in profile.js. That's why your update method isn't working. Unless I'm missing something? weratius 1 Link to comment Share on other sites More sharing options...
weratius Posted May 7, 2015 Author Share Posted May 7, 2015 Again, I'm not seeing enough code here. Sure, you could do this:// In play.js...var profile = require('./profile');module.exports = { // other state functions... update: function() { profile.update(); }};In your code examples, nothing in play.js is calling anything in profile.js. That's why your update method isn't working. Unless I'm missing something?Oh my God... I even didn't think about it, so foolish)) Thank you =) Link to comment Share on other sites More sharing options...
Recommended Posts