Jump to content

Hipst3rKiwi
 Share

Recommended Posts

hello, i was making a flappy bird clone for school and i keep on getting this error whenever i try to make my pipe functions work

 

  1. Uncaught TypeError: Cannot call method 'apply' of undefined phaser.js:39346
    1. Phaser.Timer.updatephaser.js:39346
    2. Phaser.Time.updatephaser.js:38796
    3. Phaser.Game.updatephaser.js:19712
    4. Phaser.RequestAnimationFrame.updateRAFphaser.js:34769
 
code:
 
function start() {
    birdSprite.body.allowGravity = true;
    // spawn pipes
    //  Create our Timer
    pipeT = game.time.create(false);
    //  Set a TimerEvent to occur after 2 seconds
    pipeT.loop(2000, pipeS, pipeS);
    //  Start the timer
    pipeT.start();
}
 
function pipeS() {
    //pipeT.stop();
 
    var pipeY = ((game.height - 16 - OPENING / 2) / 2) + (Math.random() > 0.5 ? -1 : 1) * Math.random() * game.height / 6;
    // Bottom Pipe
    var botPipe = makePipe(pipeY);
    // Top Pipe (flipped)
    var topPipe = makePipe(pipeY, true);
 
    // Add invisible space thingy
    var inv = invs.create(topPipe.x + topPipe.width, 0);
    inv.width = 2;
    inv.height = game.world.height;
    inv.velocity = -SPEED;
 
    //pipeT.start();
    pipeT.add(1 / SPAWN_RATE);
}
 
function makePipe(pipeY, flipped) {
    var pipes = create(
        game.width,
        pipeY + (flipped ? -OPENING : OPENING) / 2,
        'pipe'
    );
 
    // Flip pipe
    pipe.scale.setTo(2, flipped ? -2 : 2);
    pipe.offset = flipped ? -pipe.body.height * 2 : 0;
 
    // Move to the left
    pipe.body.velocity.x = -SPEED;    also for some reason im getting a problem with this
 
    return pipe;
}

 

can anyone help?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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