srikarg Posted February 7, 2014 Share Posted February 7, 2014 Hello everyone! After I updated my game to the latest release (1.1.4), I noticed a few issues with the collisions between the player and the ground. My game is set up where there are several ground sprites that are created by parsing a level text file (a ground sprite is added to a group and created on screen whenever a 'g' appears in the text file). My player is just a regular atlas sprite. After I started my game, I found these two bugs: First, my player falls through the ground occasionally (even though the ground is set to immovable) as seen below (it's a GIF): Secondly, my player fails to collide with the side of the ground sprites (even though it can easily walk on top of them) as seen in another GIF below: Can someone please help me resolve this issue? It has been annoying me for the past few hours...Thanks in advance! Here's my code (written in CoffeeScript):console.clear()game = platforms = player = cursors = nullpreload = () -> game.load.image 'sky', 'deploy/art/sky.jpg' game.load.image 'ground', 'deploy/art/ground.png' game.load.spritesheet 'coin', 'deploy/art/coin.png' game.load.atlasXML 'player', 'deploy/art/player.png', 'deploy/art/player.xml', null game.load.text 'level', 'deploy/level.txt', falsecreate = () -> game.add.sprite 0, 0, 'sky' player = game.add.sprite game.world.centerX, game.world.height - 75, 'player' player.body.bounce.y = 0.1 player.body.gravity.y = 200 player.animations.add 'left', ['left_1.png', 'left_2.png', 'left_3.png', 'left_4.png'], 10, false, false player.animations.add 'right', ['right_1.png', 'right_2.png', 'right_3.png', 'right_4.png'], 10, false, false player.animations.add 'idle', ['still.png'], 10, false, false cursors = game.input.keyboard.createCursorKeys() platforms = game.add.group() level = game.cache.getText('level').split '\n' x = y = 0 for line in level for character in line.split '' if character is 'g' platforms.create x * 32, y * 32, 'ground' x++ y++ x = 0 platforms.setAll 'body.immovable', trueupdate = () -> if player.x > game.world.width + player.width player.x = -player.width else if player.x < -player.width player.x = game.world.width + player.width game.physics.collide player, platforms player.body.velocity.x = 0 if cursors.up.isDown and player.body.touching.down player.body.velocity.y = -120 if cursors.left.isDown player.body.velocity.x = -150 player.animations.play 'left' else if cursors.right.isDown player.body.velocity.x = 150 player.animations.play 'right' else player.animations.play 'idle'game = new Phaser.Game 800, 640, Phaser.AUTO, '', { preload: preload create: create update: update}Also, here's level.txt (the text file generator for the level) if it's needed:..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ggg......gggggggggggggggggggggggggThanks again! Link to comment Share on other sites More sharing options...
jcs Posted February 7, 2014 Share Posted February 7, 2014 the 'sinking' issue sounds like a bug in the collision/separation code. i've been seeing some strange behaviours myself. if you have a solid sample of it, submit a bug to github with all the relevant info. the second issue is probably the same as issue #363 - i'm seeing the exact same thing in a side-scroller with two sprites that are standing on the same 'ground' level Link to comment Share on other sites More sharing options...
srikarg Posted February 8, 2014 Author Share Posted February 8, 2014 Thanks @jcs! Can I just reference this discussion thread in the Github Issue? Also, should I use TileSprites or a TileMap instead of the multiple ground sprites? Will that resolve this problem? /cc @rich. Link to comment Share on other sites More sharing options...
jcs Posted February 8, 2014 Share Posted February 8, 2014 collision is working properly with tile maps, to the best of my knowledge (I haven't seen any problems with it) Link to comment Share on other sites More sharing options...
jcs Posted February 8, 2014 Share Posted February 8, 2014 (I imagine you can reference this thread in the bug - Rich does read both - but be sure to link or paste the relevant info in so that the github issue is "self-documenting") Link to comment Share on other sites More sharing options...
Recommended Posts