• Content count

  • Joined

  • Last visited

About Juls

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Oh my, I can't believe it's actually working now! Thank you so much, samme!
  2. Sorry for the late response. I tried doing how you said, but in Boot.js I get this error: Uncaught TypeError: Cannot set property 'game' of undefined when writing this line: I don't know, it seems to me like I'm doing something wrong but I tried so many things..
  3. Sorry I copy pasted that part wrong, I do not have that function, I put active: function() { game.time.events.add(Phaser.Timer.SECOND, null, this); as I do not have any text to display in index.html, so no function to call in there
  4. I don't have any timer events.. I may have found the reason for this problem: I was using Google Web Fonts. TI found out that as I deleted the cache from all of my browsers, and then deleted all the code about/using google fonts, replacing the fonts with a standard one like Arial, it just works. On all browsers, without the need to refresh anything. I don't know why this is happening. For Google webFonts I followed the phaser tutorial on how to use Google webfonts and put the first part of the code in my index.html: // The Google WebFont Loader will look for this object, so create it before loading the script. WebFontConfig = { // 'active' means all requested fonts have finished loading // We set a 1 second delay before calling 'createText'. // For some reason if we don't the browser cannot render the text the first time it's created. active: function() { game.time.events.add(Phaser.Timer.SECOND, createText, this); }, // The Google Fonts we want to load (specify as many as you like in the array) google: { families: ['Revalia'] } The loader script in my Boot.js preloader: Game.Boot.prototype={ preload:function(){ // Load the Google WebFont Loader script this.load.script('webfont', '//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js'); //... And finally the font in a text object in my MainMenu.js: var txt = game.add.text(button1.x,button1.y,string, {font:"40.5px Revalia", fill: "#fff", align:"center"}); And I always had to refresh the page at least one time in order to see the font working (only when I had just cleaned the cache). Should I try some other solutions other then Google WebFonts for my fonts in the game? Or maybe am I doing something wrong while instantiating them, or is this a common issue?
  5. I guess it's not a WebGL error because using CANVAS I should never use WebGL so I don't think that's the problem.. Thank you for your answers, I edited my post as I noticed that the issue is common on any of my browsers: if I delete the cache even on Chrome or Edge I get the same problem. And only if I refresh the same page about 4-5-6 times I get things to work (which doesn't happen on Mozilla - it just happens there if I use the safe-mode version). Do you know why could this be happening?
  6. Hi everyone. I'm creating a game and I was testing it into different browsers. I always use Chrome for my tests and everything is fine there. I tried on Edge and it works perfect as in Chrome. Then I opened it in Firefox and there's a problem. It opens the preloader, the mainMenu page in which there is the name of the game and two buttons, but as I try to click on the "play" button, which brings me to the actual game, I have no answers. When I open the page I get these messages in firefox console log: I think the WebGL error is a Phaser one, because I use CANVAS in my game: (in index.html) var game = new Phaser.Game(800, 600, Phaser.CANVAS,''); And I guess that the "mozHidden" etc line is just a warning. So that TypeError must be the issue. What is the problem with those lines? What am I doing wrong with the instantiation of my game? Is it a problem that I use prototypes for my game like: (in Level1.js) Game.Level1 = function(game) { }; Game.Level1.prototype = { preload:function(game){ //... }, create:function(game){ //... } }; ? Oh, and I tried opening the game in the Firefox safe-mode, without the additional plug-ins, and it works like it should be. Any help would be really appreciated! Thank you very much. EDIT I tried deleting the cache on Chrome and Edge and it doesn't work immediately even there, giving me some phaser errors like the ones before. But no error about my code. And if I refresh the page several times, like 4 or 5 or more, it begins working again like it should. What could this problem be due to?
  7. Thanks for your answers, samme. As I try running this code outside of the preload function, exactly how you did in index.html the console gives me this error: caught TypeError: Cannot read property 'add' of null Seems like it doesn't recognize "game.plugins" when out of the preload function..
  8. I removed the onload event and have the code like this: <script type="text/javascript"> var game = new Phaser.Game(960, 640, Phaser.CANVAS,'', { preload: preload}); var slickUI; function preload() { slickUI = game.plugins.add(Phaser.Plugin.SlickUI); slickUI.load('assets/kenney/kenney.json'); } Now when I try to execute it doesn't tell anymore that "slickUI is not defined", but now it says that it "cannot read property 'add' of undefined". What is this due to?
  9. Hi everyone. I'm creating a game with Phaser for a University project and I'm trying to use Flaxis'plugin slick-ui in my project (https://github.com/Flaxis/slick-ui). I'm struggling since hours trying to get it to work. I initialized the variable slickUI, containing the plugin SlickUI, like this (following the code of a preview posted by Flaxis). In my script in index.html: window.onload = function(){ var game = new Phaser.Game(960, 640, Phaser.CANVAS,'', { preload: preload}); //adding slickUI plugin var slickUI; function preload() { slickUI = game.plugins.add(Phaser.Plugin.SlickUI); slickUI.load('assets/kenney/kenney.json'); //directory where I put kenney.json } //... } As I run this code I get no error in the console log. I thought that var slickUI, exactly as var game, was a global variable so I could be able to use it in any other .js file, but I guess I'm wrong. I tried to use slickUI variable in a file called MainMenu.js file (which is a game state, that is called after Boot.js and Preloader.js), to create a panel to be visible. My code is this: Game.MainMenu = function(game) //crea uno stato di Game { }; //prototype Game.MainMenu.prototype = { create:function(game){ var panel; slickUI.add(panel = new SlickUI.Element.Panel(8, 8, 150, game.height - 16)); //these two lines I took from the example on github }, //... } But when I try to use the variable I instantiated in the index file, that is slickUI, I get the error on console log that variable "slickUI is not defined". I tried to define and use that variable as "this.slickUI", "game.slickUI", "this.game.slickUI" but none of these worked. I also tried to instantiate the plugin directly in the MainMenu.js, but it didn't work either. So, my question is: how do I get to instantiate/call the global variable slickUI which contains the plugin, in order to be able to use it in every other .js file in the project? Your help would be so appreciated.