• Content Count

  • Joined

  • Last visited

Everything posted by Liranan

  1. Hi! I have this Phaser 3 game inside a website. It fits a div container. At some point, you can write on a HTML input to save your score. After the mobile keyboard pops up, the canvas scrolls up and everything starts to fail. The sprites coordinates stay fixed, but the canvas keeps the scroll, even when the keyboard is already closed. I think the solution may be related with the Scale Manager, but I can't figure out what. This is my configuration. Thanks! this.config = { version: '0.0.1', type: Phaser.AUTO, parent: 'phaserContainer', width: data.baseWidth, height: data.baseHeigth, scale: { mode: Phaser.Scale.RESIZE, autoCenter: Phaser.Scale.CENTER_HORIZONTALLY }, backgroundColor: '#000000', banner: { hidePhaser: false, text: '#fff00f' }, physics: { default: 'arcade' }, scene: [ Bootloader, Play, UI, Leaderboard ] };
  2. Hello Dr Popet! Thanks a lot for your comment and feedback! It means a lot for me. It makes me very happy you and your wife enjoyed the game. I wanted to do something different for the different ages since the beginning but never figured out what. The idea of changing the shapes it's really great (I specially enjoyed the concept of dinosaur shapes), I'll keep it for a future update. If your wife and you like this kind of games you may like another one of mines: Secret Codes. You can play it here: Or, if you have an android device, you can download it here: If you download Doctor Simon's Time Crash or Secret Codes in your phone and rate it you make me a big favor. Both are totally free, only with a popup Ad you can close after each game.
  3. Doctor Simon's Time Crash (Download in Google Play) Doctor Simon's Time Machine has crashed and now he is stuck in a time loop! You're his only hope to come back to the present. Memorize the shapes and colors of the combinations and click the buttons on the correct order to break the loops. Travel through time and discover new ages and backgrounds. Play with special features and bonus and unlock all the rewards to complete the game. I developed this game for Ludum Dare, a JAM event in which you have to create a game from scratch in 72 hours or less. In this case, the selected theme was 'Stuck in a loop', a tricky one. I used Phaser 3 for the coding and photoshop for designing characters, backgrounds, buttons and bars. It's my fifth game uploaded to the Google Play Store, with my Game Studio, Funsmith. All of them developed with Phaser. Here's the Google Play link to download in Android devices: If you have iOS or you want to try the game but not download it in your phone, here's a HTML link. But please, remember, if you like it, download it!
  4. Hi everyone. I'm trying to learn something about how to load database information in my phaser games. Currently, I want to load some questions for a quizz game from a SQL database. I've searched online and I found a method that works but I don't know if it's the best option. Making a XMLHttpRequest I can load a PHP file in which I load the db info and then parse it into a JSON. As I said, it works, but then I don't know how to send the results back to the game, since is an asynchronous proccess. Let me explain myself with the code: Quizz.Game.prototype = { create: function(){ this.getQuestion(); }, getQuestion: function(){ var request = new XMLHttpRequest();'POST', 'getQuestion.php', true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); request.onload = function(){ if(request.status >= 200 && request.status < 400){ //Correct var result = JSON.parse(request.responseText); this.sendQuestion(result); } else{ //Error } } request.send(); }, sendQuestion: function(){ //The next code } }; In this example I tried to load the question and then print it on screen or something, but I get the error 'this.sendQuestion()' is not a function, seems like the context is no longer 'this'... I guess my question is if you have some procedure you usually use for do this, or if there's a better way of doing it. Thank you for sharing! Gonzalo.
  5. Ok, I got it, I expected this so... no big problem. Thank you for your answers and your wisdom.
  6. Hello friends. I've a security question. I've done two mini-games for my company. I really enjoyed the chance of using Phaser in my work and not for fun, as I usally do. My boss liked it too, so good news. But he is concern because everybody are able to see the code with the elements inspector. My question is if there's some easy way to hide or protect the code from visitors, in order to avoid that our competititors steal the code for their own pages. Any advice? Thanks a lot!
  7. Amazing Game! Greaper you did a fantastic work on here. At first sight it looks like the classic idea too complicated to work well, but when you start playing you realize it's not. Its original, well-done and fun to play. Congratulations. In the other hand, I found an error. if you click too fast in several tiles, the monster appears but it doesn't die. This happens if you click in a square with a monster inside before the previous animation ended. I had all the 4-level monsters at the end of the game, and when I was sure, I clicked on all pretty fast. Some of the monsters didn't die and the game didn't end, even when there were no more 'rocks' to destroy. Either way, good job! Gonzalo.
  8. Really interesting game Skeptron. I specially like the graphics and animations. Great work! Maybe you should tell the commands somewhere before the game starts (I speak for the desktop version) I found the first robot with 3 stars unbeatable hehe. Congrats!
  9. Thank you for your answers. Tom Atom, you're absolutely right, I was being inaccurate while naming my variables. I should call 'state' to the variable I received in the constructor. I already fixed that. I tried passing to parameters (this as the state and as the game) but for some reason it didn't work. Str1ngS, you give me the solution. I change the context in the function, from 'state' to ''. By doing this, I can use the variable from the state function and I can also add the animations. Anyway, you're probably right about the static variable. The final code looks like this, in case somebody has the same doubt in the future: MyGame.Game = function(){ this.tileSize = 80; }; MyGame.Game.prototype = { create: function(){ for(var i = 0; i < 8; i++){ for(var j = 0; j < 8; j++){ var tile = new Tile(this, i, j); this.add.existing(tile); } } } }; Tile = function(state, column, row){ var posX = state.tileSize * column; var posY = state.tileSize * row;,, posX, posY, "tile"); this.state = state; this.animations.add('shine', [0, 1, 2, 3], 4, true);'shine'); }; Tile.prototype = Object.create(Phaser.Sprite.prototype); Tile.prototype.constructor = Tile;
  10. Hello Rich, I've recently finished the Interphase book.

    I found it really interesting and helpful and I've noted you called it 'chapter 1'. I guess my question is, are there any news about the chapter 2?

    I can't wait to learn more from you, in a comprehensible and clear language.

    Thank You.


  11. Hello everyone. I'm learning about extending classes so excuse me if I'm asking a silly question. What I want is to get a variable from the state and use it in the extending class constructor and functions. The state looks similar to this MyGame.Game = function(){ this.tileSize = 80; }; MyGame.Game.prototype = { create: function(){ for(var i = 0; i < 8; i++){ for(var j = 0; j < 8; j++){ var tile = new Tile(this, i, j); this.add.existing(tile); } } } }; Then, I've a extended class like this: Tile = function(game, column, row){ var posX = game.tileSize * column; var posY = -game.tileSize + (game.tileSize * row);, game, posX, posY, "tile"); = game; }; Tile.prototype = Object.create(Phaser.Sprite.prototype); Tile.prototype.constructor = Tile; It works fine, it creates the tilegrid and I'm able to use the "tileSize" value I've defined in the state function. The problem happens when I try to add some animations to the tile class. If I add the "this.animations.add('shine'...)" command in the constructor, I get an error (this.animations is not defined) I've searched in the forum and I've found a solution, instead of "var tile = new Tile(this, i, j)" I should use "var tile = new Tile(, i, j)" That's correct, if I do that, I can add the animations, but then I cannot use the state variable "tileSize". Is there a way to do both things at the same time? Thanks a lot. Liranan.
  12. Thank you a lot Rick, it worked pretty good. I'm keeping my system for some things because I need to re-order some of the element's depth, but the 'addChild' function will help me with some minor elements. One of the (many) good things Phaser have is you can have an answer from the guy who do the code. Thanks!
  13. Hello everyone, I have this doubt (little introduction before): I think is really helpful to use a sprite property to "store" another sprite. For example, when I have several enemies and I want all of them to have a health bar I can do something like this: var enemies =; for(var i = 0; i < 5; i++){ var enemy = game.add.sprite(0, 0, "enemy", 0); var health = game.add.sprite(enemy.x, enemy.y, "bar", 0); = health; enemies.add(enemy); } By doing this, I can easily locate the health bar in the game later. For example if I want to change the bar's frame I only have to: enemies[i].health.frame = 1; I can do this several times, for example if I want to add a magic bar to the enemies, a text with the name, etc. The problem is, when I want to move the enemy sprite. At this moment, I create a tween for the 'main' sprite, and another tween for each of the properties: game.add.tween(enemies[i]).to({...}); game.add.tween(enemies[i].health).to({...}); game.add.tween(enemies[i].magic).to({...}); This is ok when you have just one property for each sprite, but when the numbers go up, it starts to look... problematic. Specially when each enemy have different properties. I was wondering if there's a way to move a sprite and 'all the sprites that belongs to them' at the same time with a single tween. Thank you! Gonzalo.
  14. That's it! It works perfectly! Thank you very much Gob0!
  15. Mmm, it sounds good but I had the same answer for 'mainState.myFunction()' Uncaught TypeError: mainState.myFunction is not a function If I move the listener and the function out of the prototype it works, but it's useless to me because I've to refer the elements inside the prototype
  16. Hello Gob0 and thanks for your answer. I'm sure the problem is about the reference "this" but I use it in all the functions of the game and it always works but this time, I assume for being inside the document listener. I've tried with 'myClass' but it doesn't work either. This is an example of how the code is set if it helps: var mainState = function(){}; mainState.prototype = {create: function(){game.input.onUp.add(this.test, this); //this worksdocument.addEventListener('mouseout', function(){ this.test(); }); //this doesn't work},update: function(){ },test: function(){console.log("test correct");}}; I've also tried this solution update: function(){game.input.mouse.mouseOutCallback = this.test();} But it acts like the mouse always was outside the screen. If I launch the game, the console writes endless texts no matter if the mouse is on the screen or out I've also tried checking in the update function if the mouse coordinates were in or out the screen. At last, it was the method that worked better, but still sometimes miss the movement.
  17. Thanks for the answer drhayes I've tried doing this: document.addEventListener('mouseout', function(){ this.myFunction(); }); But didn't work. It said "myFunction" didn't exists (and it did). I'm guessing you can't launch a phaser game function inside a DOM listener
  18. Hello everyone, here's my issue. In the game you make lines in a tilemap by click (input.onDown) and moving the cursor over them. When you release the cursor (input.onUp) the lines disapear. The problem is: when I move the cursor out the screen, it doesn't detect the event as input.onUp, and I can release the button, come back to the screen and select a new line without destroying the previous one. What I want to know is: is there some way to launch a function when the cursor (in web or mobile) leaves the screen? I've tried some methods, but none of them worked. Thanks!
  19. Thank you lewster32, I guess I have to learn how to create classes soon or later, and this is a good moment. I found this tutorial: In case someone have the same problem than I
  20. Hello everyone! I'm a starter on Phaser, I did some small examples and now I'm working on a bigger game. My code is growing and growing and it has become difficult to read. I use 5 js files: load, boot, menu, game and main. Main is where I write most of the code. I was wondering if it's possible to create other files and attach them to the main state somehow. For example, write all the level creation code in one file and call it from the main.js file... Like an include on php. I guess my question it's dumb for some of you, hehe, what can I say... I'm new! Thank you very much. Liranan.
  21. Liranan

    Glow effect

    Hello arkerone. I have the same question. I was searching a bit on internet and it seems that there's no an easy way to do it. Overlap another sprite will do the job, but I think it's not the fanciest method... It's weird that you can't do it with tweens... Let's see if someone have other solution.
  22. Hello parwanikaprash I just found a code that works fine and do exactly what you're looking for: If you have a 'boot.js' file, you can put these lines on the 'create' function game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;game.scale.pageAlignHorizontally = true;game.scale.pageAlignVertically = true;game.scale.setScreenSize(true);I tried it and works wonderful. Hope I helped you! Gonzalo.