• Content count

  • Joined

  • Last visited

  1. P2 Tile bodies

    How can i add physics bodies to specific tiles without colliding with them?
  2. Sometimes this error occurs after destroying a sprite. Uncaught TypeError: Cannot read property 'GetType' of null at box2d.b2Fixture.GetType (box2d-plugin-full.min.js:9) at box2d.b2ContactFactory.Create (box2d-plugin-full.min.js:9) at box2d.b2ContactManager.AddPair (box2d-plugin-full.min.js:9) at box2d.b2BroadPhase.UpdatePairs (box2d-plugin-full.min.js:9) at box2d.b2ContactManager.FindNewContacts (box2d-plugin-full.min.js:9) at box2d.b2World.Step (box2d-plugin-full.min.js:11) at Phaser.Physics.Box2D.update (box2d-plugin-full.min.js:13) at c.Physics.update (phaser.min.js:3) at c.Game.updateLogic (phaser.min.js:3) at c.Game.update (phaser.min.js:3) $.each(client.entities, function(i,v){ if (v.nametag){ v.nametag.destroy(); } v.destroy(); delete client.entities[i]; }); Should i call body.destroy before? Setting body.removeNextStep to true must delete body correctly but it doesn't trigger an event so i don't know when to delete sprite. Phaser CE v2.7.10
  3. I noticed that sprite.x/y doesn't have any effect on player coordinates in Phaser CE v2.7.10. However, sprite.body.x/y works perfectly. What is sprite.x/y for?
  4. Need help scaling TilemapLayer

    I'm trying to scale a tilemap using TilemapLayer.setScale but it blurs tiles, is there any way to scale tilemap with full quality? Phaser's scaling: https://prnt.sc/fsgcfz Tiled zoom: https://prnt.sc/fsgcp3
  5. Last active pointer

    How can i find the last active pointer? I'm looking for something like this: game.input.onDown.add(oninputdown, this); function oninputdown(pointer){ lastPointer = pointer; }
  6. About the stage

    I get this error when restarting Game state. This line causing the error: this.player.healthbar = new HealthBar(this, {x:this.player.x, y:this.player.y-25, height:5, width:50}); It's all fine if i call world.removeAll in the state.shutdown function. shutdown: function(){ this.world.removeAll(); } Why am i have to call world.removeAll after switching states? Shouldn't it clear the game world itself when game.state.start is called? Docs says "but not the Stage, so if you've added your own objects to the Stage they will need managing directly" Is healthbar added to the Stage? If so, What is the stage? I'm using phaser.healthbar plugin to create health bars.
  7. Responsive game

    For desktop devices, there's no bounds even without _definedSize. (for scaleMode SHOW_ALL) For mobile devices, there's world bounds set to screen size. this.world._definedSize = true; this.stage.disableVisibilityChange = true; this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; It doesn't let me replace world bounds with Box2D's setBounds method, only world.setBounds. I need to have world bounds with Box2D bodies. this.physics.box2d.setBoundsToWorld(); // or this.physics.box2d.setBounds(0, 0, 19200, 19200); // same as box2d.setBoundsToWorld() since it doesn't use x,y,width,height. // No effect
  8. Responsive game

    What's the difference between this.scale.scaleMode = Phaser.ScaleManager.RESIZE; this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; and this.scale.setResizeCallback(function(obj,rect){ this.scale.setGameSize(rect.width, rect.height); }, this); I need to use Box2D's world bounds but scaleMode RESIZE sets it's own bounds to the world and i can't replace it. With setResizeCallback everything works fine (i think, at least.) Can I use Box2D's world bounds with scaleMode RESIZE if there's a big difference?
  9. Phaser and mobile games

    I want to put my game to Play Store, I googled it a bit and found Cordova and CocoonJS. I'm planning to use Box2D plugin and websockets for the game so my questions are: Which one is faster? I don't want to use CocoonJS if i don't have to since it adds a "built with Cocoon" splash. Is websockets supported? Is it possible to read & write files, show notifications? Can I use Google Play Games Services? How can I monetize my game? Is there an easy way to add ads? Thanks.
  10. Responsive game

    I need to change x,y coordinates of texts, sprites etc. when screen size changes. I made something like this, but i don't think this is the right solution. How can i do this directly with Phaser? document.getElementsByTagName("body")[0].onresize = function(){ var w = window.innerWidth * window.devicePixelRatio; var h = window.innerHeight * window.devicePixelRatio; // Game size if(w != game.width || h != game.height) { game.scale.setGameSize(w, h); } // UI HPText.cameraOffset.y = h-245; Text1.cameraOffset.y = h-325; Text2.cameraOffset.y = h-305; Text3.cameraOffset.y = h-285; Text4.cameraOffset.y = h-265; } Is it possible to scale sprites/texts for all devices? If so, how? I couldn't find an easy solution for that. Also, what does game.scale.setShowAll() do? Can't find this function in the docs.
  11. [SOLVED] Minimap performance

    Works well if you minus x,y by the size of player's rectangle. Use final solution instead, this doesn't work correctly. this.mmgraphics.drawRect(player.x/this.mmgraphics.timesby+this.mmgraphics.padding-10,this.camera.height+player.y/this.mmgraphics.timesby-this.mmgraphics.padding-this.mmgraphics.screensizeH-10,10,10); Edit: Final solution Just minus screensize values by rectangle size. // create this.mmgraphics.timesby = (((this.mmgraphics.mapWidth/(this.mmgraphics.screensizeW-5))/2)+((this.mmgraphics.mapHeight/(this.mmgraphics.screensizeH-5))/2)); // update this.mmgraphics.drawRect(((entity.x/this.mmgraphics.timesby)+this.mmgraphics.padding),(this.camera.height+(entity.y/this.mmgraphics.timesby)-this.mmgraphics.padding-this.mmgraphics.screensizeH),5,5); You can change timesby on update function to have rectangles in different sizes.
  12. [SOLVED] Minimap performance

    I actually tried that before, didn't work tho.
  13. [SOLVED] Minimap performance

    I fixed it by increasing mmgraphics.mapWidth and mmgraphics.mapHeight values by 1000. It's perfectly fit now. Edit: I only changed mapWidth. There's no problem with mapHeight, weird.