Search the Community
Showing results for tags 'globals'.
-
Hello, I'm trying to get Pixi to work with nwjs but I get some errors in pixi's platform.js. It doesn't seem to recognize some globals. First of all it gave undefined for global.document, which I was able to fix by adding a line to my script: global.document = window.document; // Fix pixi document contextHowever, right after I get the next error, apparently global.Image is undefined. Since I have no idea what global.Image is supposed to be or do I'm stuck and don't know how to proceed.
-
Hi everyone Coming here as AS3 developer, I have almost zero JS experience previously Perhaps what I'm missing is proper JS coding knowledge, I'm sorry if I posted at the wrong section I'm building a test project using latest Phaser. So far so good! Have managed to create some things visible, tween, bitmaptext and spritesheet working, and learn a few tricks in the way. My only complaint is that coding Phaser JS on Sublime Text is a pain when compared with coding AS on FD and I'm too lazy to give Typescript a try. Currently I'm using the template from the nice codevinsky http://codevinsky.ghost.io/phaser-tutorial-getting-started-with-generator-phaser-official/ Very helpful to add new States easily and made my life easier with its pre-configured grunt task. My problem now is how to make a Global class so that I can access it from anywhere. In AS3, I can easily create a new generic class and use it anywhere else. I'm sure this has something to do with the way JS works, but I really want to write customer's game logic in a separate file (TCustomer.js) I really have no idea how to include / import it to my play.js, if it's at all possible. Have tried a few ways, but none were successful. So far here's my code: window.onload = function () { var game = new Phaser.Game(800, 480, Phaser.AUTO, 'phaser-sandwich-test'); // Game States game.state.add('TCustomer', require('./states/TCustomer')); game.state.add('TSaveManager', require('./states/TSaveManager')); game.state.add('TWindow', require('./states/TWindow')); game.state.add('boot', require('./states/boot')); game.state.add('globals', require('./states/globals')); game.state.add('menu', require('./states/menu')); game.state.add('play', require('./states/play')); game.state.add('preload', require('./states/preload')); game.state.start('boot');};With the code above, I can access TCustomer and TWindow anywhere I want. But the problem is, they are both NOT game states. I'm pretty sure there must be a better way to do this. Will there be a problem if I keep adding new global classes as game states? Thanks in advance!