Jump to content

Problem with collision?


Aerion
 Share

Recommended Posts

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

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. " :D

Link to comment
Share on other sites

 

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

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...