aitim Posted August 6, 2014 Share Posted August 6, 2014 sorry for my english. here is my player sprite and there are my codevar game = new Phaser.Game(1280, 720, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render});function preload() { game.load.spritesheet('player', 'assets/boyz.png', 100, 144); game.load.image('ground', 'assets/platform.png'); game.load.image('floor', 'assets/floorsprite.png'); game.load.image('tree', 'assets/tree.png'); game.load.tilemap('map', 'assets/map1.json', null, Phaser.Tilemap.TILED_JSON);}var platforms;var left = false;function create() { map = this.add.tilemap('map'); map.addTilesetImage('floor'); map.addTilesetImage('tree'); blocked = map.createLayer('blocked'); blocked.debug = true; layer = map.createLayer('tree'); layer = map.createLayer('ground'); map.setCollisionBetween(0, 100); game.physics.startSystem(Phaser.Physics.ARCADE); platforms = game.add.group(); platforms.enableBody = true; var ground = platforms.create(0, game.world.height - 64, 'ground'); ground.scale.setTo(6, 2); ground.body.immovable = true; var ledge = platforms.create(400, 450, 'ground'); ledge.body.immovable = true; ledge = platforms.create(-150, 250, 'ground'); ledge.body.immovable = true; player = game.add.sprite(20, game.world.height - 144*3, 'player'); game.physics.arcade.enable(player); player.body.gravity.y = 300; player.body.collideWorldBounds = true; player.animations.add('left', [1, 2, 3, 4], 10, true); player.animations.add('right', [6, 7, 8, 9], 10, true); player.body.gravity.y = 300; game.camera.follow(player); cursors = game.input.keyboard.createCursorKeys(); }function update() { game.physics.arcade.collide(player, blocked); player.body.velocity.x = 0; if (cursors.left.isDown) { player.body.velocity.x = -200; player.animations.play('left'); left = true; } else if (cursors.right.isDown) { player.body.velocity.x = 200; player.animations.play('right'); left = false; } else { player.animations.stop(); if(left == true) player.frame = 0; else{ player.frame = 5; } } if (cursors.up.isDown && player.body.touching.down) { player.body.velocity.y = -380; } if (!player.body.touching.down) { if(left == false) player.frame = 10; else{ player.frame = 11; } }}function render() {}this is the result my player touching tile map but it not display 5th sprite frame and cannot jumphow can I solve? Thank you Link to comment Share on other sites More sharing options...
aitim Posted August 9, 2014 Author Share Posted August 9, 2014 no one answer TT_TT Link to comment Share on other sites More sharing options...
kidos Posted August 10, 2014 Share Posted August 10, 2014 Sorry to bring this up, hopefully someone in the future will search for it. Since you're using tilemap, instead of using:player.body.touching.downthis should work:player.body.blocked.down kctang 1 Link to comment Share on other sites More sharing options...
kctang Posted October 15, 2014 Share Posted October 15, 2014 Exactly what i needed. Thank you very much @kidos! Link to comment Share on other sites More sharing options...
Recommended Posts