Problem Collision player Jump

Hi

I have problem, player collision not detect my code is:

[code]
$.playground()
.addGroup("bg",{posx: 0, posy: 0, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
.addTilemap('tilemap', map, animations, {width: 25, height: 25, sizex: 20, sizey: 18}).end()
.addGroup("player", {posx: 400, posy: 335, width: MONKEY_WIDTH, height: MONKEY_HEIGHT})
.addSprite('monkeyup', { posx: 72, posy: 0, width: MONKEY_WIDTH, height: MONKEY_HEIGHT})
.addSprite('monkey', {animation: playerAnimation["normal"], posx: 0, posy: 0, width: MONKEY_WIDTH, height: MONKEY_HEIGHT})

$.playground().registerCallback(function(){



if(jQuery.gameQuery.keyTracker[87] && ACTIVE_JUMP == 0){ //this is left! (a)
ACTIVE_JUMP = 1;
}

if(ACTIVE_JUMP==1 && ((inicialY-altosalto) < $("#player").y()) ){
saltoY = $("#player").y()-5*gravedad;
$("#player").y(saltoY);
} else if(ACTIVE_JUMP==1 || ACTIVE_JUMP==2){
ACTIVE_JUMP=2;
saltoY = $("#player").y()+5*gravedad;
$("#player").y(saltoY);
}

$("#player").collision("#tilemap .gQ_tile").each(function(){
console.log(1);
// do something with the id
});



}, REFRESH_RATE);


[/code]

Comments

  • Accepted Answer
    Hi,

    $("#player").collision("#tilemap .gQ_tile") shoud be $("#player").collision("#bg,#tilemap,.gQ_tile")

    Because you have to add in the filter all the parents too. Don't worry groups and tilemaps are not returned by this function, only tiles and sprites

    Hopes it solves your problem!
  • Hi, I solved with

    this.collision().each(function(){
    //el jugador collisiono con gQ_tile que es la parte del mapa
    if($(this).hasClass("gQ_tileType_0")){
    ACTIVE_JUMP=0
    }
    });

    This can be done?, or am I using it incorrectly?
  • You can do it... It may be a bit slow at time and adding a filter is a way to optimize it but other than that it's the correct usage!
Sign In or Register to comment.