Search the Community

Showing results for tags 'p2'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Platform
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 335 results

  1. Hello, In the tiled map editor is a tilecollision editor i was just wondering if there is any way to get the stuff u do in there to work in phaser, or any other way to set a specific collision polygon to a tile.
  2. I'm working on a Pachinko-like game and have a question about physics. I'm new to Phaser, so if this is an obvious answer, sorry! I have a star-shaped pin wheel thing. I need it to be stationary but rotate around its anchor point when hit by an object (based on physics). How would I go about making it stationary, but allowing it to be rotated based on objects colliding with it? (I know how to get the polygon collision using the Physics Editor, I'm just not sure about the rotation part). Any help will be greatly appreciated! Thanks.
  3. Our new tool, Loon Physics, has just been released to open beta for free! Try it now to export P2 Physics body polygons for Phaser. Use a URL to test live without exporting files. Use Loon Physics here: Learn how to make a game with P2 Physics using this brand new tutorial:
  4. We recently released a tool for editing P2 Phyics body polygons called Loon Physics. Check it out here: Read a tutorial about P2 Physics bodies and Loon Physics here: Do you find Loon Physics useful? Do you encounter any bugs when using the tool? Any suggestions?
  5. Loon Ride, the epic loon game, has received major updates on all platforms! Collect loons, shoot cacti, and soar through endless mode. This game was made using Phaser. Read more about the game here: Play the game in your browser here: Get the game on Google Play here: Promo video:
  6. hi, i'm coding a pinball game in js with phaser and p2physics. I search how i can do rotation with a anchor point. I want create the rotation for the flipper but method rotateLeft or rotateRight do the rotation by the center's sprites. I want create a rotation around topleft and top right point of the sprite to do a flipper movement. orry for my bad english, thx.
  7. I made an example of how you can mimic a skeleton/bodyparts using LockConstraints in P2 physics. I thought it might be useful to share it/ add to the Phaser examples , for people looking for ways to use joints/ lock constraints in their game. here is the example: The sprites I used are from my own game, but you could very well replace it with any other sprites... In the code I also explained how it works.
  8. Hello guys I'm making a platformer game, I struggled with making collision between the player and objects created in tiled but after that I got it working with a function I created, however, when I make the rectangle rotated in tiled, in the game it comes out away from its position, take a look: this is on tiled in the game it comes out like this here is my code, createCollisionObjects is where the magic happens var game = new Phaser.Game(70 * 10, 70 * 7, Phaser.AUTO, 'game', { preload: preload, create: create, update: update, render: render }); function preload() { // tilemap game.load.tilemap( 'map', 'assets/tilemaps/maps/lvl-1.json', null, Phaser.Tilemap.TILED_JSON ); // tilemap images game.load.image('new', 'assets/tilemaps/tiles/new.png'); game.load.image('sheet', 'assets/tilemaps/tiles/sheet.png'); game.load.image('s9af', 'assets/tilemaps/tiles/s9af.png'); // player spritesheet game.load.atlasJSONHash( 'player', 'assets/spritesheets/player_walk.png', 'assets/spritesheets/player_walk.json' ); } /* * GLOBAL VARIABLES */ var map; var player; var playerSpeed = 400; var jumpTimer = 0; function create() { game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.setBoundsToWorld(true, true, true, true, false); game.physics.p2.gravity.y = 300; game.physics.p2.restitution = 0; game.stage.backgroundColor = '#ffffff'; map = createMap().map; var start = map.objects.objective[0]; player = createPlayer({x: start.x, y: start.y}); cursors = game.input.keyboard.createCursorKeys(); } function update() { player.body.setZeroVelocity(); if (cursors.up.isDown && > jumpTimer && checkIfCanJump()) { player.body.velocity.y = 600; jumpTimer = + 750; } if(cursors.left.isDown) { player.body.velocity.x = -playerSpeed;'walk'); } else if (cursors.right.isDown) { player.body.velocity.x = playerSpeed;'walk'); } else { player.body.velocity.x = 0; player.animations.stop(); player.frame = 0; }; } function render() { } function createMap() { var m, g, f, b, c; m = game.add.tilemap('map'); var mWidth = m.widthInPixels; var mHeight = m.heightInPixels;, 0, mWidth, mHeight); m.addTilesetImage('sheet', 'sheet'); m.addTilesetImage('new', 'new'); m.addTilesetImage('s9af', 's9af'); g = m.createLayer('ground'); f = m.createLayer('fringe'); b = m.createLayer('background'); g.resizeWorld(); f.resizeWorld(); b.resizeWorld(); createCollisionObject(m.objects.objects); return { map: m, ground: g, fringe: f }; } function createPlayer(pos) { var p = game.add.sprite(pos.x, pos.y, 'player', 'Symbol 2 instance 10000'); //p.scale.setTo(0.4, 0.4); game.physics.p2.enable(p); p.body.setZeroDamping(); p.body.fixedRotation = true; p.body.x+=p.width/2; p.body.y+=p.height/2; // animation p.animations.add( 'walk', Phaser.Animation.generateFrameNames('Symbol 2 instance 1000', 0, 7, '', 1), 10, true, false); //'walk-left'); return p; } function createCollisionObject(objects) { if (objects) { for(var i=0; i < objects.length; i++) { var p2 = game.physics.p2; var obj = objects[i]; var sprite = game.add.sprite(obj.x, obj.y, null); sprite.width = obj.width; sprite.height = obj.height; sprite.angle = obj.rotation; game.physics.p2.enable(sprite, false); sprite.body.x = sprite.x + sprite.width / 2; sprite.body.y = sprite.y + sprite.height / 2; sprite.body.rotation = obj.rotation; sprite.body.static = true; sprite.body.debug = true; } } } function checkIfCanJump() { var yAxis = p2.vec2.fromValues(0, 1); var result = false; for (var i = 0; i <; i++) { var c =[i]; if (c.bodyA === || c.bodyB === { var d =, yAxis); // Normal dot Y-axis if (c.bodyA === d *= -1; if (d > 0.5) result = true; } } return result; }
  9. Hi, I am getting some unwanted behaviour with groups and p2 physics. When the sprites is leaving the screen, I want to kill them and reset new ones. But when I kill the first one, and reset a new one, the physics goes haywire. Anyone got a suggestion on how to fix this? Check this pen for an example:
  10. I need to check if one object (Sprite/p2 body/shape) contains another object. In p2 documentation I found only Contact event, but I need to know when body inside sensor or other area. In Phaser I found Phaser.rectangle.containsRect, this is what I need but Rectangle do not support rotation as I understand. So fail (( With AS3 and Nape I did it this way: if(Geom.contains(outShape, inShape)){.....} How I can do it in Phaser and/or p2 physics ?
  11. Hi to you all. Hi have a question. I'm making a platformer game using phaser and , for now, arcade physics. I make my level in Tiled and export them in JSON. I noticed that since Tiled work with png tileset and that tiles are square. My character do not detect a slope or slante corner. It stands on a invisible cube border. What i was wondering is, is it possible for phaser to detect slanted slope using arcade or should i move to P2JS. Also how do I tell phaser to ignore the transparent part and collide only with the image? I tried making object layer coutouring all the platform for a more precise collision but it seems i'm not able to create a collision layer with a Tiled object layer. or maybe i'm doing it wrong. function create() { map = game.add.tilemap('niveau2'); map.addTilesetImage('tileset','background'); map.addTilesetImage('hints','hints'); backgroundLayer = map.createLayer('background'); collisionLayer = map.objects.evenement.find( o => == 'platform'); collisionLayer.visible = false; console.log(collisionLayer); map.setCollisionByExclusion([],true,collisionLayer); collisionLayer.resizeWorld(); //map.setCollision(1) player = game.add.sprite(32, - 150, 'star'); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; player.body.gravity.y=10050; // Our controls. cursors = game.input.keyboard.createCursorKeys(); } function update() { game.physics.arcade.collide(player, collisionLayer); //more code }
  12. Hi, 1 month ago, I started looking into physics coz I've wanted to make a pinball game (I own 5 real games and am a bit of Pinball freak). So I started looking at physics, which I never had used before (I made some other Phaser games before) Anyway, P2 seemed good enough and I also found this demo by forum member george : So I worked from that and I now have this : Still a work in progress, but It plays quite nicely I think.. What I would like to add is *active* elements that not just bounce the ball back, but kick it back when hit. I can register a hit and then need the bumpers and slingshots to kick the ball away (on top of the bounce) What would be the best way to achieve this ? I tried using body,reverse but that is producing strange effects.. I can think of these options : always apply the same restitution value for bumpers and slingshots (so not dependent on speed of ball) - but that's probably not possible create a virtual kicker using P2 that kicks the ball (seems pretty hard to do for a bumper because it's a circle that can be hit from any direction) create a reverse force for the pinball Anyone has any ideas or pointers ? Besides this - would box2d be better for pinball then P2 ? thanks for any input or feedback.
  13. Hi guys! I'd like to make a computer object in my game, such that when player approches to the computer,it triggers onEnter callback ( where I can for example show a message on screen to press certain key ) and when player goes away it triggers onLeave callback ( where I can hide the message ). In order to achieve that I need two colliders, one for regular collision ( red one ), and the other to detect if the player entered computer's zone ( green one, this is the one that I want to trigger callback ). = 9 * TILE_WIDTH + COMPUTER_WIDTH / 2, TILE_HEIGHT + COMPUTER_HEIGHT / 2, 'computer' ); ); = true; TILE_WIDTH, TILE_HEIGHT, COMPUTER_WIDTH / 2, COMPUTER_HEIGHT / 2 ); this.computersCollisionGroup = ); this.playerCollisionGroup, () => console.log( 'player in range' ) ); this.player.body.collides( this.computersCollisionGroup ); My question is: How do I turn off physical collision in green collider and what to do to make green collider trigger onEnter and onLeave callbacks ?
  14. Hi! If I use p2 physics what is the most effective way to add slopes to my tilemap? I use tiled. I saw a solution here (below) where you make the tile layer with the slope tiles non-collidable, and you make an object layer on top of that where you draw polylines, and make the object layer collidable, but thats not that efficient if you design a level and want to try out a lot of variations. So my question is, is there a more efficient way of doing this? For example like in ninja physics where you can associate the tiles with different shapes.
  15. Hi all, I'm trying to have my bullets group that already collides with the enemies, both of them are a group, but now that I want to add a static block or obstacle, it simply wont collide or overlap or nothing, what I want is that when the bullet collides or overlaps it gets destroyed or at least bounce into the obstacle, see code below: ////////////////My Bullets//////////These work fine and collide correctly with my enemies.////// createBullets: function() { this.bullets =; this.bullets.enableBody = true; this.bullets.physicsBodyType = Phaser.Physics.P2JS; this.bullets.createMultiple(100, 'bulletSprite', 0, false); this.bullets.setAll('anchor.x', 0.5); this.bullets.setAll('anchor.y', 0.5); this.bullets.setAll('outOfBoundsKill', true); this.bullets.setAll('checkWorldBounds', true); }, fireBullet: function(){ if (this.bulletTimer < { this.bulletTimer = + 500; this.bullet = this.bullets.getFirstExists(false); if (this.bullet) { this.bullet.reset(this.tanke.x, this.tanke.y - 20); this.bullet.body.setCollisionGroup(this.bulletCG); this.bullet.body.collides([this.figuraCG]); this.bullet.body.velocity.y = -3500; } } }, //////This is the block or obstacle this just wont work no matter what I try/////////// makeOneBloque: function(){ this.bloque =, 950, 'Blokes'); this.bloque.enableBody = true;, true); this.bloque.body.kinematic = true; this.bloque.body.collides(this.bullets, this.collisionBulletBloque, this); //////I tried overlaps and it just crashes the lvl }, collisionBulletBloque: function(bullet) { bullet.sprite.destroy(); }, I would greatly appreciate any help or suggestions.
  16. Rafaelx


    Trying to create a group, but keeps saying it is undefined got any suggestions? Please see code below. this is defined in the create function: this.bloqueCG =; makeOneBloque: function(){ this.bloque =; this.bloque.enableBody = true; this.bloque.physicsBodyType = Phaser.Physics.P2JS; this.bloque.create(200, 950, 'Blokes'); this.bloque.create(550, 950, 'Blokes'); this.bloque.create(900, 950, 'Blokes'); this.bloque.body.setCollisionGroup(this.bloqueCG); <<<<----I get error here :( this.bloque.body.collides(this.bulletCG, this.hitBloke, this); this.bloque.body.kinematic = true; this.bloque.setAll('anchor.x', 0.5); this.bloque.setAll('anchor.y', 0.5); this.bloque.setAll('outOfBoundsKill', true); this.bloque.setAll('checkWorldBounds', true); },
  17. Hi All I have spend all night trying to figure this out. I changed my game from Arcade to P2 physics and can not for the life of me get collisions to work. I changed my body types to Kinematic since I don't need any physics applied to my object. Below is my code : createEnemies: function() { var enemy = enemies.getFirstExists(false); if (enemy) { enemy.reset(500,; enemy.body.fixedRotation=true; enemy.body.kinematic = true; enemy.body.velocity.y = -100; enemy.anchor.setTo(0.5, 0.5); enemy.body.moves = true; enemy.body.debug = true;[0].sensor = true; enemy.scale.set(scaleRate); enemy.body.onBeginContact.add(blockHit, this); // DOES NOT TRIGGER //enemy.body.collides(bulletsCollisionGroup, hitEnemy, this); // DOES NOT TRIGGER } If I change my body from Kinematic = true, to Kinematic = false, then all the events trigger. Any ideas?
  18. How to detect the object from group when collided to player in p2. like: Arcade child from group ex:
  19. in this game i need physics for multiple objects for a group its fine to enable p2 bt whenever i tried to enable p2 for player with this line game.physics.p2.enable(player, false); my screen goes black why is this happening ??? var game = new Phaser.Game(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.AUTO, '', { preload: preload, create: create, update: update}); var player; var world; var blink; var rocketangel; var rocketdirection; var rocketSpeedDelta; var rocketradius; var platforms; var scoreText; var playerangle; var scaleRatio; var score; var asteroid; scaleRatio = window.devicePixelRatio / 2; //load images or files before game starts function preload() { game.load.image('background', 'assets/game/background.png'); game.load.image('world', 'assets/game/world.png'); game.load.image('player', 'assets/game/player.png'); game.load.image('blink', 'assets/game/blink.png'); game.load.image('asteroid', 'assets/game/asteroid.png'); } //create all the images ans things on the screen function create() { score=0; rocketangel = 0; rocketdirection = 1; rocketSpeedDelta = 0.002; rocketradius = 170; playerangle=60; // A simple background for our game game.add.sprite(0, 0, 'background'); // We're going to be using physics, so enable the Arcade Physics system game.physics.startSystem(Phaser.Physics.P2JS); // Turn on impact events for the world, without this we get no collision callbacks game.physics.p2.setImpactEvents(true); game.physics.p2.restitution = 0.8; // Create our collision groups. One for the player, one for the pandas var playerCollisionGroup = game.physics.p2.createCollisionGroup(); var asteroidCollisionGroup = game.physics.p2.createCollisionGroup(); world=game.add.sprite(,, 'world'); world.anchor.setTo(0.5, 0.5); world.scale.setTo(scaleRatio, scaleRatio); platforms =; platforms .enableBody = true; platforms.physicsBodyType = Phaser.Physics.P2JS; for (var i = 0; i < 10; i++) { asteroid = platforms.create( , , 'asteroid'); asteroid.anchor.setTo(0.5, 0.5); asteroid.scale.setTo(scaleRatio, scaleRatio); game.physics.p2.enable(asteroid, false); asteroid.body.setRectangle(40, 40); // Tell the panda to use the pandaCollisionGroup asteroid.body.setCollisionGroup(asteroidCollisionGroup); // Pandas will collide against themselves and the player // If you don't set this they'll not collide with anything. // The first parameter is either an array or a single collision group. asteroid.body.collides([asteroidCollisionGroup, playerCollisionGroup]); } //adding player player = game.add.sprite(,, 'player'); player.anchor.setTo(0.5, 0.5); player.scale.setTo(scaleRatio, scaleRatio); //game.physics.p2.enable(player, false); //player.body.setCircle(28); // Set the ships collision group //player.body.setCollisionGroup(playerCollisionGroup); // The ship will collide with the pandas, and when it strikes one the hitPanda callback will fire, causing it to alpha out a bit // When pandas collide with each other, nothing happens to them. //player.body.collides( asteroidCollisionGroup, hitPanda, this); // The platforms group contains the ground and the 2 ledges we can jump on //asteroid.body.collideWorldBounds = true; // The score scoreText = game.add.text(16, 16, 'score: 0', { fontSize: '32px', fill: '#FFF' }); scoreText.scale.setTo(scaleRatio, scaleRatio); cursors = game.input.keyboard.createCursorKeys(); } function hitPanda(body1, body2) { // body1 is the space ship (as it's the body that owns the callback) // body2 is the body it impacted with, in this case our panda // As body2 is a Phaser.Physics.P2.Body object, you access its own (the sprite) via the sprite property: body2.sprite.alpha -= 0.1; } function update() { var playerangelchange; platforms.forEachAlive(moveBullets,this); platforms.forEach(function(asteroid) { game.physics.arcade.collide(player,asteroid,deathHandler, null, this); }, this); //keypress if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) { //it will speed up the rocket } else if (game.input.keyboard.isDown(Phaser.Keyboard.ENTER)) { //it will cause the blink blink= game.add.sprite(player.x, player.y, 'blink'); blink.anchor.setTo(0.5, 0.5); blink.scale.setTo(scaleRatio, scaleRatio); game.add.tween(blink).to( { alpha: 0 }, 20, Phaser.Easing.Linear.None, true); //blink.destroy(true); } else if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { rocketdirection=-1; //change the direction } else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { rocketdirection=1; //change the direction } //speed of current rocket movement if (rocketdirection == 1) { rocketSpeedDelta = 1.14; playerangelchange=1.1; } else if (rocketdirection == -1) { rocketSpeedDelta = -1.14; playerangelchange=-1.1; } //for moving on a circular path scoreText.text = 'Score: ' + score; rocketangel += this.time.physicsElapsed * rocketSpeedDelta ; player.x = Math.cos(rocketangel) * rocketradius ; player.y = * rocketradius ; playerangle+=playerangelchange; player.angle=playerangle; } function moveBullets (asteroid) { setTimeout(accelerateToObject(asteroid,world,30),50000); //start accelerateToObject on every bullet } function accelerateToObject(obj1, obj2, speed) { if (typeof speed === 'undefined') { speed = 60; } var angle = Math.atan2(obj2.y - obj1.y, obj2.x - obj1.x); //obj1.body.rotation = angle + game.math.degToRad(90); // correct angle of angry bullets (depends on the sprite used) obj1.body.force.x = Math.cos(angle) * speed; // accelerateToObject obj1.body.force.y = Math.sin(angle) * speed; } function deathHandler() {"gameover"); }; </script> </body> </html>
  20. Hi, I´ve been using Phaser version 2.4.2 and everything has been working fine expect for triangle collision shapes made in TIled. They trigger collisions with setPostBroadphaseCallback even if a sprite is not colliding with the shape. Oddly it only affects slopes. So i´ve tried updating Phaser to the ce edition if that would remove the bug, but only got a new one. My players sprite is spawned on the right edge of the screen. Changing world.setBounds doesnt make a difference. Also im unable to create the players sprite anywhere else in its create function. The x and y coords have no effect. What changed in Phaser version 2.4.7 that broke my game? 2.4.7 Is the version after the bounds bug appears. Any help would be appreciated.
  21. My problem is the position of the sprite is not correct when using accelerateToObject function. Running accelerateToObject function in sprite: Without accelerateToObject function in sprite: Of course I need accelerateToObject function to follow the player. Thanks in advance
  22. I don't know why this error is happening: This code has a problem and I don't know why: this.enemy.body.collides(objectsCollisionGroup, function(){enemies[].jump();}); My full code: Enemy_1 = function (index, game, player) { var x =; var y =; = game; = Math.floor((Math.random() * 20) + 5);; this.player = player; this.alive = true; this.punchedCount = 0; this.enemy = game.add.sprite(x, y, 'stickman_2'); = index.toString(); this.enemy.punching = false; game.physics.p2.enable(this.enemy); this.enemy.animations.add('left', Phaser.Animation.generateFrameNames('walk/left_', 1, 8), 10, true); this.enemy.animations.add('right', Phaser.Animation.generateFrameNames('walk/right_', 1, 8), 10, true); this.enemy.animations.add('sprint_left', Phaser.Animation.generateFrameNames('walk/left_', 1, 8), 20, true); this.enemy.animations.add('sprint_right', Phaser.Animation.generateFrameNames('walk/right_', 1, 8), 20, true); this.enemy.animations.add('punch_1_left', Phaser.Animation.generateFrameNames('punch_1/left_', 1, 3), 20, true); this.enemy.animations.add('punch_1_right', Phaser.Animation.generateFrameNames('punch_1/right_', 1, 3), 20, true); this.enemy.checkWorldBounds = true; this.enemy.body.collideWorldBounds = true; this.enemy.body.fixedRotation = true; this.enemy.body.damping = 0.5; this.enemy.body.setCollisionGroup(enemies_1ColisionGroup); this.enemy.body.collides(blockCollisionGroup); this.enemy.body.collides(objectsCollisionGroup, function(){enemies[].jump();}); this.enemy.healthBar = game.add.text(0, 0, 'HP: ' + + '%', {font: "10px Arial", fill: "#ffffff"}); this.enemy.addChild(this.enemy.healthBar); this.enemy.healthBar.position.y = this.enemy.healthBar.position.y-80; }; Enemy_1.prototype.damage = function() { -= 1; if ( <= 0) { this.alive = false; this.enemy.kill(); return true; } return false; }; Enemy_1.prototype.punch = function () { if(this.enemy.facing == 'left') {'punch_1_left'); this.enemy.punching = true; if(this.player.facing == 'left') { this.player.body.x += 1; } else { this.player.body.x -= 1; } } else {'punch_1_right'); this.enemy.punching = true; } }; Enemy_1.prototype.jump = function () { if(checkIfCanJump(this.enemy)) { this.enemy.body.moveUp(300); } }; Enemy_1.prototype.update = function() { this.enemyMoves = false; //<Enemy_Punch> if(checkOverlap(this.enemy, player)) { if(playerPunching == true){ if(this.enemy.body.velocity.x < 0 && this.enemy.body.velocity.y < 150 && this.enemy.body.velocity.y > 0) { this.enemy.body.x += 30; } else if(this.enemy.body.velocity.x > 0 && this.enemy.body.velocity.y < 150 && this.enemy.body.velocity.y > 0) { this.enemy.body.x -= 30; } enemies[].damage(); } else { playerPunching = false; } * 0.5, function(){enemies[].punch();}, this); } else { this.enemy.punching = false; this.enemyMoves = true; if(this.enemyMoves != false) { accelerateToObject(this.enemy, this.player, 200); } if(this.enemy.body.velocity.x < 0 && this.enemy.body.velocity.y < 150 && this.enemy.body.velocity.y > 0) {'left'); this.enemy.facing = 'left'; } else if(this.enemy.body.velocity.x > 0 && this.enemy.body.velocity.y < 150 && this.enemy.body.velocity.y > 0) {'right'); this.enemy.facing = 'right'; } } //</Enemy_Punch> if(this.enemy.punching != false) { playerSubtractHealthBar(0.5); } this.enemy.healthBar.setText('HP: ' + + '%'); }; Add the enemies in the game: Thanks in advance
  23. I'm trying to make a prototype for a RPG game, I managed to make the drive, but I can't do the collision, can help? I have the ' background ' layer, that would be my floor, the 'colisao', where I keep all objects that the player will collide, as walls, and finally the 'coletaveis', where the items that the player can interact. Follow my code level 1: Not even the collision with the edge of the screen is working, can anyone help me?
  24. crffty


    Hi. I'm trying to make my first game with Phaser and I'm trying to get some physics working - global gravity. I'm not sure whats going on but somethings not working: = { create : function() { this.background =, 0,, 360, 'background'); this.background.autoScroll(-100, 0); this.background =, 290,, 8, 'ground'); this.background.autoScroll(-180, 0); this.player = this.add.sprite(30, 230, 'player'); this.player.animations.add('run');'run', 10, true); // physics engine; // gravity = 400; }, based on a couple tutorials I've been following I was expecting for the 'ground' to fall, but it does not. I'm still really new to Phaser and kinda new to JS, so i figure I'm overlooking something simple. I actually only need gravity on the player sprite so if you could suggest how to go about that I would appreciate in but would be happy just to get some gravity of any kind to start with. Thank you in advance for your help.
  25. Hello everyone, this is my first time posting on this forum, which means I'm pretty desperate at this point haha! I'm trying to make a simple game where a character is sliding down a hill, this is what I got so far: I want to make the hill as slippery as ice, just like some ice parts in this game: I learned a lot from this game btw. I tried to copy how the user made his ice material, but it doesn't seem to work in my game! // Create ramp and player from tiles sharp =,"points"); player =,10, 'player'); // Define materials groundMaterial =; playerMaterial ='player'); // Give the ramp material for (i=0; i<sharp.length; i++){ sharp[i].setMaterial(groundMaterial); } // define what happens when one material contacts the other, groundMaterial, { friction: 0 , restitution: 0 }); What am I doing wrong? Please help me