Jump to content

Search the Community

Showing results for tags 'collision-detection'.

  • 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. I have a tilemap with multiple layers that should be impassable. I tried multiple times with setCollision() and setCollisionBetween() but could never get it to work, so I decided to do a bit of hard-coding. I have a 32 x 32 tile-map and this function works for 2 out of 4 directions. The directions this works for are right and down. I can solve this easily if I can just figure out the problem with one direction. I simplified this code as much as possible. The moveUp() function is the one that doesn't work, whereas the moveDown() function is the one that's working. function moveUp(map, layers) { if (layers.every(layer => !map.hasTile(x, y - 1, layer))) { hero.body.velocity.setTo(0, -150); } else { stopMovement(); } } function moveDown(map, layers) { if (layers.every(layer => !map.hasTile(x, y + 1, layer))) { hero.body.velocity.setTo(0, 150); } else { stopMovement(); } } Here is information on the hasTile() function. https://phaser.io/docs/2.6.2/Phaser.Tilemap.html#hasTile x: X Position to check if a tile exists y: Y Position to check if a tile exists Layer: The layer to set I'm checking whether the map has a tile in the collision layers at the player's X Position on the tile map and the Y Position is the tile directly above or below the player. If there is no collision tile, the player is free to walk. When a player moves up, there is an entire tile that a player cannot access (32px), whereas, when a player moves down, there is no space. To demonstrate this, take a look at the attachments. The problem probably lies with the coordinates of the collision sprite. . I can't figure out what I'm doing wrong here.
×
×
  • Create New...