Barthandelus Posted November 29, 2017 Share Posted November 29, 2017 Hi, I'm a actually making a game using PHASER. On this game, player have to jump to escape balls rolling on the ground, like on an infinite runner. Actually, everything is working fine but the player is showed using a spritesheet divided on 128*128 resolution. The character animation running doesn't use 128 pixels on width causing the ball to collide with the player even if the player doesn't hit the ball. The player hitbox is actually configured to 128*128 but I know that in previous versions of PHASER, it was possible to render player to make his hitbox scale his skin. I didn't find this function in the actual version of PHASER. Can someone help ? Thanx in advance. For information : Quote game.load.spritesheet('character', './ressources/characterRunning.gif', 128, 128); [...] // Player. player = game.add.sprite(100, 450, 'character'); game.physics.arcade.enable(player); player.scale.setTo(0.75, 0.75); player.body.gravity.y = 2000; player.body.collideWorldBounds = true; player.animations.add('running', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 10, true); player.animations.add('jump', [2], 10, true); player.animations.play('running'); Phaser example on previous versions : Quote gameState.main.prototype = { ... render: function() { this.game.debug.renderPhysicsBody(this.bird.body); } }; Link to comment Share on other sites More sharing options...
Fenopiù Posted November 29, 2017 Share Posted November 29, 2017 Reading the doc, I've understand that Arcade physics works on rectangle, so (if I've understood correctly) if you want to make player hitbox scale his skin, you have to use P2 or Ninja physics. Link to comment Share on other sites More sharing options...
Barthandelus Posted November 29, 2017 Author Share Posted November 29, 2017 Ok, I understand. Solution found using Arcade Physics : Quote player.body.setSize(53, 100, 25, 15); This permit to define a custom hitbox on a sprite. Don't hesitate to use the RENDER function to help you. Problem solved ! Link to comment Share on other sites More sharing options...
Recommended Posts