Jump to content

Collision between ground and items


QuentinIcky
 Share

Recommended Posts

Hi all ! 

I'm new to phaser, I would like to create an event when items collide to the ground. The items are generated randomely. 
 

//Add items
    emails = level2.add.group();
    emails.enableBody = true;
    emails.physicsBodyType = Phaser.Physics.ARCADE;

//Generate items 
for (var y = 0; y < 2; y++) {
        for (var x = 0; x < 10; x++) {
            var mail = emails.create(5 + x * 94, y * 10, 'email');
            mail.name = 'mail' + x.toString() + y.toString(); // ??
            mail.checkWorldBounds = true;
            mail.events.onOutOfBounds.add(mailOut, this);
            mail.body.velocity.y = 150 + Math.random() * 200;
        }
    }

I tried this :

//Create collision
level2.physics.arcade.overlap(ground, emails, fbiCollect, null, this);

//enemy collect 
    function enemy() {
        console.log('in enemy collect')
        mail.kill();
        scoreEnemy += 10;
    }

But it doesn't work.. So if anyone has an idea

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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