• Content Count

  • Joined

  • Last visited

About tomfog

  • Rank

Recent Profile Visitors

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

  1. Update: I have tried the following with no luck: solidBlock = game.add.sprite(167, 400, 'solidBlock'); game.physics.p2.enable( [ solidBlock ]); // first I tried this solidBlock.body.static = true; // then I tried this solidBlock.body.kinematic = true; Any help or advice would be much appreciated!
  2. Thanks for help with this! I'm still struggling to understand how this works. I'm trying to make a demo game where shapes are dynamically dropped into a box inside the game. All the shapes are placed inside a collision group using p2 physics and are set to collide with the world bounds like this: game.physics.p2.updateBoundsCollisionGroup(); var game = new Phaser.Game(640, 1000, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });, 0, 322, 594);, 0, 640, 1139); mainBG = game.add.sprite(0, -3522, 'mainBG'); // this is a tall image, I plan to scroll bg later I am using the code above and here is a screenshot of how I want it to behave - so that the dynamically created shapes are fixed inside the world bounds (drawn in screenshot with the yellow box): Currently I can drag and drop the shape outside of the yellow box on the left-hand side - but they are restricted to the right and bottom edges as expected. I'm really not sure what I'm doing wrong?! Thanks
  3. I have used this phaser example as a starting point to build a game where shapes are dynamically dropped from the top of the screen and collide with each other: What I would like is for the shapes to stop bouncing and vibrating when they collide - but I'm not sure which settings to adjust to achieve this effect (and I've not had much luck with trial and error so far!). I have set gravity like this: game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 6000; Here is my shapes/sprites json file: { "shapeOne": [ { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 84, 76 , 0, 160 , 0, 0 , 84, 0 ] } , { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 84, 76 , 314, 76 , 314, 160 , 0, 160 ] } ], "shapeTwo": [ { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 0, 0 , 315, 0 , 315, 83 , 0, 83 ] } ], "shapeThree": [ { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 0, 0 , 237, 0 , 237, 235 , 0, 235 ] } ] } Does anyone know the correct settings to adjust? Do I need to turn density up really high and friction low? And should gravity be high? Here is a screenshot of the shapes that are being dropped into the container:
  4. Hi, I am trying to modify the 'Pick Up Object' phaser example: How it should work is that when a user clicks on one of the shapes at the bottom of the screen it should generate a new shape inside the yellow containing block. I want the shapes to restricted inside the yellow box so that they cannot pass outside. Here is my demo version: I have tried the following code - but I am not sure what is going wrong with the boundaries - any help/suggestions would be much appreciated! var game = new Phaser.Game(640, 1139, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); // set the world bounds to match the yellow container, 0, 306, 500); // center camera, 0, 640, 1139); // load the background - this is larger than the screen var mainBG = game.add.sprite(0, -3622, 'mainBG'); // add shapes/buttons to the shapeMenu button1 = game.add.button(80, 760, 'button1', actionOnClickButton, this, 2, 1, 0); button2 = game.add.button(254, 800, 'button2', actionOnClickButton, this, 2, 1, 0); button3 = game.add.button(486, 770, 'button3', actionOnClickButton, this, 2, 1, 0); Then the logic for placing the shapes follows the 'Pick Up Object' example - using PS physics ands boundsCollisionGroup... Thanks!
  5. Thanks for replying! If I wanted to add a background image that takes up the full game canvas - at full height and width and sits behind world's custom bounds, would this be possible? And if so - do I need to add the sprite to the stage or the world? Thanks you
  6. Hi, I did try that - but it moved the 'shapeMenu' sprite as well. This really confused me as I thought this element would not be affected as it's outside of the world bounds? Thanks
  7. Hi I have a newbie question that I feel silly asking but I couldn't find an example that demonstrated this yet. I have set the size of the canvas using the following code: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'new-phaser-game', { preload: preload, create: create, update: update, render: render }); I have added a sprite that sits at the bottom of the screen full width (as expected) using the following: shapeMenu = game.add.sprite(0, 500, 'shapeMenu'); Now I would like to resize the world so that it sits inside this area with a margin around it (but inside the canvas). I have done this, but the world is sitting in the top left corner:, 0, 400, 400); Could any one advise on how I move this to the center of the screen (without moving the shapeMenu sprite as well)? Thanks!
  8. Hi I'm new to phaser and have been trying to use some of the examples as a starting point. I'm planning on using the "Pick Up Object" example, but restrict the area that the tetris shapes are placed in - so that they land on a solid platform. I would then add 3 x buttons to add more of the shapes onto the screen. Example here: Would the best way to achieve this be to build the solid platform using a kinematic sprite as documented here: If not, what is the best way define the area that the shapes are placed in - so they do not fall behind or in front of the platform and buttons? Thanks! Tom