Jump to content

Search the Community

Showing results for tags 'border collision'.

  • 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. Hi guys, I have a strange problem. I've created a tilemap and player sprite. Collision between them works, but I need to know on which side of the player the colission happend. I've llocked through the examples and the docs and found .body.touching.X. So, this was exactly what I was looking for. But it doesn't work. Down,up,left and right are always false. Even in the moment when the player sprite touches a collision tile. The variable "none" of body.touching is always true. Any help would be great! Here's some code I'm using: function create() { // setting global gravity to 100 game.physics.gravity.y = 100; cursors = game.input.keyboard.createCursorKeys(); // adding the tilemap created with Tiled map = game.add.tilemap('current_level'); map.addTilesetImage('tiles', 'tiles'); // the gray tiles shall be responsible for collisions, check the tiles.png, the first one is the gray one map.setCollisionBetween(0, 1); // loading the layer from the tilemap, the layer name got defines in the Tiled editor map_layer = map.createLayer('Level'); map_layer.resizeWorld(); map_layer.debug = true; // show the bounding boxes for collisions // creating and adding the player sprite player = game.add.sprite(50,400,"player"); player.body.collideWorldBounds = true; // don't move out of the screen player.body.immovable = true; // no bouncing or other fancy physics stuff for the player player.body.linearDamping = 0; // the button to change the gravity button = game.add.button(250,400, 'gravity_button', action_flip_gravity, this, 2, 1, 0); button.body.allowGravity = false; } function update(){ // update collision checks for the player an the map every update cycle game.physics.collide(player, map_layer,collide_player_with_world);}function collide_player_with_world(player,map_layer){ console.log("collide_player_with_world none: " + player.body.touching.none); if(!player.body.touching.down && game.physics.gravity.y > 0){ console.log("collide_player_with_world down: " + player.body.touching.down); move_to_x = null; move_direction = 0; player.body.velocity.setTo(0,0); } }
×
×
  • Create New...