Aerion Posted October 11, 2017 Share Posted October 11, 2017 Hi all. I'm having a problem with collision. I basically need to allow the player ( Luigi ) to stand on top of the 1st pipe in the demo, and press the down arrow to activate in this case as a test, make him die and delete. Also I need to get Luigi in this mario clone I made to "bump" his head on a block and make the block jump up and back down like in the NES mario game? Here's the demo I uploaded : http://babylontesting.epizy.com/Phaser.js/super-mario-bros-clone-in-phaser/ Here's the file that allows for the collision : http://babylontesting.epizy.com/Phaser.js/super-mario-bros-clone-in-phaser/js/index.js the lines for the pipe collision callback function are lines 587 - 627 var pipeOverlap = function(player, pipe) the lines for the brick collision callback function are lines 629 - 669 var brickOverlap = function(player, pipe) Thank you all so much for the help! <3 ~M Link to comment Share on other sites More sharing options...
Ryzahhh Posted October 11, 2017 Share Posted October 11, 2017 This is just a thought I am totally a noob. Have you tried making an if statement like this: if (key is down [and] player on top of pipe) collide luigi and pipe = false else if (player on top of pipe) collide luigi and pipe = true "This isn't actual code just a concept I thought of as I read. " Link to comment Share on other sites More sharing options...
samid737 Posted October 11, 2017 Share Posted October 11, 2017 Looks like onFloor() is true in pipeOverlap() while it shouldn't. If your pipe is part of a tilemap that would explain it. You can use player.body.blocked.down to check if the player bottom is touching the pipe. For the brick you can do it the other way around, player.body.blocked.up. For the brick motion you could pass the colliding objects to your callBack function and do stuff with the tile, but im not sure if the tiles will physically move... If not, you could try add an extra dummy brick sprite that has A tween attached to it and play the tween at the location of the tile whenever collision occurs. Something like this: game.physics.arcade.collide(sprite, layer,bump); function bump(sprite,tile)//in this order { //tile.alpha=0; //play brick tween moving up and down tween here. //tween.resume(); //tween.onComplete.add(function(tile){tile.alpha =1},this); } Link to comment Share on other sites More sharing options...
Aerion Posted October 11, 2017 Author Share Posted October 11, 2017 It's still registering the pipeOverlap ( ) function on ALL sides of the pipe View Source : view-source:http://babylontesting.epizy.com/Phaser.js/super-mario-bros-clone-in-phaser/js/index.js Source : http://babylontesting.epizy.com/Phaser.js/super-mario-bros-clone-in-phaser/js/index.js Demo : http://babylontesting.epizy.com/Phaser.js/super-mario-bros-clone-in-phaser/ see lines 592 - 594, you'll notice I changed it to "if ( player.body.blocked.down ) { }" Thanks! <3 ~M Link to comment Share on other sites More sharing options...
Aerion Posted October 12, 2017 Author Share Posted October 12, 2017 Need more detail? Link to comment Share on other sites More sharing options...
Aerion Posted October 13, 2017 Author Share Posted October 13, 2017 Anyone? Link to comment Share on other sites More sharing options...
Aerion Posted October 14, 2017 Author Share Posted October 14, 2017 I've tried everything I can think of... To no avail. I don't understand... Link to comment Share on other sites More sharing options...
samme Posted October 14, 2017 Share Posted October 14, 2017 Turn on debug on all the tilemap layers. phaser-plugin-debug-arcade-physics can show you the sprite's blocked/touching edges. body.blocked.down will be true if set by any of the previous collisions, not just the current one. So if the guy is standing on the ground next to the pipe, it will still be true. Link to comment Share on other sites More sharing options...
Aerion Posted October 16, 2017 Author Share Posted October 16, 2017 I must apologize. This debug plugin is a little too difficult for me to implement. I don't use terms like "this" or "prototype". I just do normal "var myfunc = function ( blah . . . ) { . . . . }". I just wanna be able to press down on the top of the pipe & have my player kill himself as a test. Thank you! ~M Link to comment Share on other sites More sharing options...
Recommended Posts