Jump to content

Search the Community

Showing results for tags 'setcollision'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 2 results

  1. Hi. I want to make a collision between character and tiles so that character couldn't go through the tiles, but nothing works. <script> var game = new Phaser.Game(800, 600, Phaser.AUTO); var player; var cursor; var map; var layer; var GameState = { preload: function() { this.load.image('character', 'assets/character.png'); this.load.tilemap('map', 'assets/tile_csv.csv', null, Phaser.Tilemap.CVS); this.load.image('tiles', 'assets/tile.png'); }, create: function() { game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = "#0000ff"; map = game.add.tilemap('map', 32, 32); map.addTilesetImage('tiles'); layer1 = map.createLayer(0); layer1.resizeWorld(); map.setCollision(2); player = game.add.sprite(50, game.world.height - 110, 'block'); game.physics.arcade.enable(player); player.anchor.setTo(0.5); player.scale.setTo(0.4); player.body.collideWorldBounds = true; cursors = game.input.keyboard.createCursorKeys(); game.camera.follow(player); }, update: function() { game.physics.arcade.collide(player, layer1); player.body.velocity.x = 0; player.body.velocity.y = 0; if (cursors.left.isDown) { player.body.velocity.x = -1500; } else if (cursors.right.isDown) { player.body.velocity.x = 1500; } if (cursors.up.isDown) { player.body.velocity.y = -1500; } else if (cursors.down.isDown) { player.body.velocity.y = 1500; } } }; game.state.add('GameState', GameState); game.state.start('GameState'); </script>
  2. I have a question about a breakout type game. All the square blocks are sprites in a Phaser.group and they're layed out in a grid pattern. The player breaks the blocks by boucing a ball against them. The problem is that the ball movement isn't always quite right. When the ball bounces off the side of a column or row of blocks, it sometimes deflects back in the opposite direction which is incorrect. I know the cause of this, see the example image in the attachment.The ball collides with all the blocks (using arcade physics) and sometimes it collides with the bottom part of a block. In the example image it bounces against both brick 1 and 2, but because it collides with the bottom part of brick 1 it rebounds back downward. I could set the body.checkCollision.down=false for block 1, and set it correctly for all the blocks according to their position to other blocks etc. However the problem then becomes that every time a block is removed it has to be rechecked for all the blocks (set body.checkCollision.up correct again) according to the new block layout. For example in the attachment image, at first brick 1 must not check the bottom collision, so body.checkCollision.down = false. But when brick 2 is removed, then it DOES have to check the bottom as well. I think a Phaser.tilemap isn't a good solution either, because the tiles (i.e. the blocks) need to be removed as the game is played, and a Phaser.tilemap isn't optimal for someting like that. So what is a good way to implement this, without the rebound errors?
×
×
  • Create New...