mardi 11 avril 2017

Mario pass through the top of a platform even if the collision was detected (flash CS6)

i am trying to develop a plataform game in flash cs6. I created a class called Plataforma in which a method called enterFrameEvents is responsable for verifying if a platform of such class has collided with mario.

However, no matter what I do, it detects that mario has collided with its top, but mario pass through the platform. But it does not happen when he collids with the bottom and the other sides.

I am pasting a link with my code

In the stage there are two blue platforms which are ocorrences of "plataforma" symbol. Class Plataforma is an actionscript class automatically generated by the flash for "plataforma" symbol.

Here I am pasting the code

   private function enterFrameEvents(event:Event):void{ 

        // collision with top
        if(mario.y + mario.height >= this.y &&  mario.y <= this.y &&
         mario.x + mario.width >= this.x + 5 && mario.x <= this.x + this.width - 5 ){

         _root.isJumping = false;
         _root.speedY = 0;
          mario.y = this.y - mario.height;  

I am discount 5 pixels from the corners.

Thank you!

Aucun commentaire:

Enregistrer un commentaire