• Content Count

  • Joined

  • Last visited

  1. can you write me an example code?
  2. I have problem when i restart the game! I do it with this line of code'BootState');The problem is that when the game restarted there are strange behaviours during the game. How can i delete all data for each state and reboot the game from the first state!
  3. I tried the code in the post that you have suggested me, but i have a problem, the game is not correctly resized. This is my code:BootState.prototype = { preload : function(){ ;}, create: function(){ = 'game'; this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.minWidth = gameWidth/2; this.scale.minHeight = gameHeight/2; this.scale.maxWidth = gameWidth; this.scale.maxHeight = gameHeight; if ({ this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; this.scale.setScreenSize(true); }else{ this.scale.maxWidth = 2048; //You can change this to gameWidth*2.5 if needed this.scale.maxHeight = 1228; //Make sure these values are proportional to the gameWidth and gameHeight this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; this.scale.forceOrientation(true, false); this.scale.hasResized.add(this.gameResized, this); this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this); this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this); this.scale.setScreenSize(true); } var ow = parseInt(,10); var oh = parseInt(,10); var r = Math.max(window.innerWidth/ow,window.innerHeight/oh); var nw = ow*r; var nh = oh*r; = nw+"px"; nh+"px"; = (window.innerWidth/2 - nw/2)+"px"; = (window.innerHeight/2 - nh/2)+"px"; document.getElementById('game').style.width = window.innerWidth+"px"; document.getElementById("game").style.height = window.innerHeight-1+"px";//The css for body includes 1px top margin, I believe this is the cause for this -1 document.getElementById("game").style.overflow = "hidden"; game.state.start('GameState'); ;}, update : function(){ ;}}BootState.prototype.gameResized = function(width, height){}BootState.prototype.enterIncorrectOrientation = function(){document.getElementById('game').style.display = 'block';}BootState.prototype.leaveIncorrectOrientation = function(){document.getElementById('game').style.display = 'none';}
  4. I have a problem with the resizig. When I do the resizing of the page I get this result: Currently when I open the page I get the result in the figure below instead I would like to have the same results that I have with the resize. This is the portion of the interesting code: var w = window.innerWidth * window.devicePixelRatio,h = window.innerHeight * window.devicePixelRatio;var game = new Phaser.Game(w,h, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render }); function gameSet(){ game.scale.maxWidth = 1920; game.scale.maxHeight = 1080; game.scale.startFullScreen(); game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.forceLandscape = true; game.scale.setScreenSize(true); game.scale.setShowAll(); game.scale.refresh() } function create() { [...] gameSet(); [...] }
  5. I have the same problem that there is in this example: When I move the mouse very quickly, not all the pixels are plotted! How can i resolve this problem?
  6. I resolved my problem! I substitute: background = game.add.tileSprite(0, 0,w,h,bmd); with background = game.add.sprite(0, 0, bmd);
  7. Below there is my code, 'where' gesture is an instance of a class that contain a bitmap. <html> <head> <title>Game</title> <script type="text/javascript" src="js/dollar.js"></script> <script type="text/javascript" src="js/phaser.min.js"></script> <script src=""></script> <script src="js/gesture.js"></script> </head> <body> <script> var w = window.innerWidth * window.devicePixelRatio,h = window.innerHeight * window.devicePixelRatio; var game = new Phaser.Game(w, h, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render }); var platforms,gesture,ground; var solidH = 100,solidW = 100; var bmd; function preload() { /*Imposta limiti di risoluzione 2048x1536 retina display */ game.scale.maxWidth = 1920; game.scale.maxHeight = 1080; /*Vogliamo scalare fino a quando possibile, ma proporzionalmente*/ game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.setScreenSize(); game.load.image('forest', 'assets/bksprite.png'); game.load.image('ground', 'assets/solid.jpg'); } function create() { platforms =; platforms.enableBody = true; ground = platforms.create(0, - solidH, 'ground'); //adesso creiamo il ground ground.body.immovable = true; // questo impedisce la caduta del ground ground.body.collideWorldBounds=true; bmd = game.add.bitmapData(w,h); bmd.context.fillStyle = '#00CCFF'; bmd.context.fillRect(0,0,w,h); bmd.context.fillStyle = '#FFFFFF'; background = game.add.tileSprite(0, 0,w,h,bmd); } var k=10; function update() { bmd.context.fillStyle = '#FFFFFF'; bmd.context.fillRect(k,10, 10, 10); k=k+10; } function render(){ } </script> </body> </html> I don't understand because the square is drawn once. I obtain one white square at position x=10 y=10 and not a line.
  8. I have a problem: In my game there are a group of stars that get down from the sky. The collision star-ground doesn't work when the stars begin get down before the camera moved.
  9. Hi lewster32, thanks for your help.
  10. What is the best way to create an enemy at run time? Actually, i wrote this code: var position = % 500; if ((position>= 0&&position<=10&&enemies.countLiving()==0) && != 0) { var random_number = Math.random() * 100; if (random_number >= 0 && random_number <= 50) { enemy = enemies.create(, - enemyH - solidH, 'enemy'); rifbomb = w; enemy.body.collideWorldBounds = true; enemy.frame = 1; enemy.body.velocity.x = -80; } }
  11. how can i set the background color of my bitmap data? function create() { bmd = game.add.bitmapData(800, 600); bmd.context.fillStyle = 'rgba(255,255,255, 0.3)';'red'; game.add.sprite(0, 0, bmd); _points = new Array(); _r = new DollarRecognizer(); }
  12. nunziox

    Paint in a game

    I need of painting into a canvas while the game is run. I'd want to set the physic at the painted element. is it possible?
  13. nunziox

    BMP vs Jpeg

    Wow.!!! tinypng is very interesting !!! thanks to all for the responses!
  14. nunziox

    BMP vs Jpeg

    I made my game in js using phaser. My game is wrapped into android app using the WebView, therefore all resources are stored in local. My question is: In term of performance the best solution is use bmp images (without compression) or jpeg images?