Jump to content

Search the Community

Showing results for tags 'spritebody'.

  • 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 1 result

  1. Hello everyone ! I was doing some experiments with Phaser to understand it and ran into what seemed like a big problem to me which I would like to share. Here's the demo : (removed) Basically the sprite bodies do not seem to follow the sprites accurately at all, and the collisions aren't working well either, with the badnik running straight into the map. I was not sure if these two issues were related or not and since my source code seems simple I decided to put them in the same topic. Here's the source : (function () { var game = new Phaser.Game(800, 400, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.spritesheet('sonic', 'sonic_running.png', 36, 36, 4); game.load.spritesheet('badnik', 'badnik.png', 40, 30, 4); game.load.image('starfield', 'starfield.jpg'); game.load.tilemap('spacelevel', 'tiles-1.png', 'spacelevel.json', null, Phaser.Tilemap.JSON); } var keys = Phaser.Keyboard; var jumpTimer = 0; var sonic,bg, map; function create() { bg = game.add.tileSprite(0, 0, 3000, 500, 'starfield'); map = game.add.tilemap(0, 0, 'spacelevel'); map.setCollisionRange(0, 69, true, true, true, true); sonic = game.add.sprite(36, 36, 'sonic'); sonic.anchor.setTo(0.5, 0.5); sonic.body.collideWorldBounds = true; sonic.body.gravity.y = 100; sonic.animations.add('run'); sonic.animations.play('run', 30, true); game.camera.follow(sonic); badnik = game.add.sprite (400,40, 'badnik'); badnik.body.collideWorldBounds = true; badnik.body.gravity.y = 100; } function update() { game.physics.collide(sonic, map); game.physics.collide(badnik, map); game.physics.collide(sonic, badnik); if (game.input.keyboard.isDown(keys.SPACEBAR)) { if (sonic.body.touching.down && game.time.now > jumpTimer) { sonic.body.velocity.y = -600; jumpTimer = game.time.now + 500; } } if (game.input.keyboard.isDown(keys.LEFT)) { sonic.body.velocity.x = 400; } sonic.body.velocity.x = 400; } function render() { // game.debug.renderSpriteCorners(sonic); // game.debug.renderSpriteCollision(sonic, 32, 32); game.debug.renderSpriteBody(sonic); game.debug.renderSpriteBody(badnik); }})();I am using Phaser 1.0.6a and was able to reproduce the issue on both Firefox and Safari (haven't tried on Chrome), OS X 10.8. Am I doing something wrong ? Thanks a lot for Phaser !
×
×
  • Create New...