Search the Community

Showing results for tags 'touching'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 5 results

  1. Hi there. Not sure if this is an issue, but, just checked on the documentation, and it does not say anything about this behaviour... I have this code, a simple code that collides two sprites: var mainState = ( function () { var preload = function () { game.load.spritesheet('cota-cola', 'assets/cota-cola.png', 16, 33); game.load.spritesheet('carousel', 'assets/baggage-carousel.png', 50, 100); } var create = function () { var block; cotacola = game.add.sprite(150,0, 'cota-cola'); game.physics.arcade.enable(cotacola); carousel =; for (var i=0; i<5; i++) { block = game.add.sprite(100 + i*50, 100, 'carousel'); game.physics.arcade.enable(block); block.body.immovable = true; carousel.add(block); } cotacola.body.acceleration.y = 400; } var update = function () { console.log(cotacola.body.touching.down); game.physics.arcade.collide(cotacola, carousel); }; return { preload : preload, create : create, update : update };})();var game = new Phaser.Game(500, 300, Phaser.AUTO, 'game');game.state.add('main', mainState);game.state.start('main'); if i call any member of touching before the collide function, it will always be false... var update = function () { console.log(cotacola.body.touching.down); // will always print false game.physics.arcade.collide(cotacola, carousel); };but if I call it after the collide function, it will be accurate... var update = function () { game.physics.arcade.collide(cotacola, carousel); console.log(cotacola.body.touching.down); // this works fine };In the documentation it does not say anything about this behaviour. But I think that if this isn't an issue, a warning about this should be documented. Should I post this as a github issue? == EDIT == I just discovered that the behaviour I want, is actually the .wasTouching var update = function () { game.physics.arcade.collide(cotacola, carousel); console.log(cotacola.body.wasTouching.down); // this works fine};This works even if I put it before the collide var update = function () { console.log(cotacola.body.wasTouching.down); // this also works fine game.physics.arcade.collide(cotacola, carousel);};It is kind of confusing, though... because, in a bigger context, i might want to see whether a sprite 'a' is touching something or not, from the update of another sprite 'b'... and if the collide function is coded on the sprite 'a', and the check is realized from the sprite 'b', then this behavior would be very confusing if you don't know which update function gets executed first.
  2. I use the Ninja Physics library and am very happy with it. Sadly, the "touching" object won't detect collisions for non-full tiles. I use the Circle as shape for my player. Is there a function I'm missing, or is there a known workaround for this?
  3. I am having problems jumping in my game. 1st. I use key.isDown to determinate the jump of my sprite. But if I hold key of the jump, my character is jumping all the time. I want to push the key once and wait to another key press to do a new jump. 2nd. I draw the map with json using a file made by tiled. This tiles work with sprite.touching, they are not work by sprite.blocked. Then in my game I draw new blocks with sprite.create function and they work with sprite.blocked only. What is the difference? By the way I have some problems with sprite collisions in this new blocks, I can stick to the walls like this while hold left cursor. I have Phaser v2.0.5.
  4. Good Morning, I'm trying to have my 'player' sprite be able to move 'box' sprites around the screen. So far, I can push the box... but it doesn't stop moving. The effect is like the box is on ice. I touch it and it slides away. Here's my code: function update() { game.physics.arcade.collide(player, block, moveBlock, null, this);}function moveBlock() { if (block.body.touching.up) { block.body.velocity.y = 75; } else if (block.body.touching.down) { block.body.velocity.y = -75; } else { block.body.velocity.y = 0; } if (block.body.touching.left) { block.body.velocity.x = 75; } else if (block.body.touching.right) { block.body.velocity.x = -75; } else { block.body.velocity.x = 0; }}The problem seems to be that the 'else' of the statements is never "true". Now, I put a console.log statement in the 'else' portion for vertical movement, and noticed that the only time it ever responded was when I went from pushing the block vertically to horizontally. So how I do I get the dang thing to stop moving when my player sprite is not touching it? Thanks for your help!
  5. 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); } }