Jump to content

bullets.body.velocity.


vmars316
 Share

Recommended Posts

Hello & Thanks :

I am having trouble getting bullets to go :

Quote

    //  Our ships bullets
    bullets = game.add.group();
    bullets.enableBody = true;
    bullets.physicsBodyType = Phaser.Physics.ARCADE;

    //  All 40 of them
    bullets.createMultiple(40, 'bullet');
    bullets.setAll('anchor.x', 0.5);
    bullets.setAll('anchor.y', 0.5);

 

function fireBullet () {

    if (game.time.now > bulletTime)
    {
        bullet = bullets.getFirstExists(false);

        if (bullet)
        {
            bullet.reset(throwerSprite.body.x + 16, throwerSprite.body.y + 16);
            bullet.lifespan = 2000;
            bullets.body.velocity.y = -300;
//            bullets.body.acceleration.y = -300;
            bulletTime = game.time.now + 50;
        }
    }
}

 

I get error :Uncaught TypeError: Cannot read property 'velocity' of undefined  m-vertical-collision.js:124 

Pls , what do I need to make this puppy go ?

Thanks
 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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