Jump to content

cant get tilePosition of undefined


mrxj88
 Share

Recommended Posts

hey guys took a long break from phaser and decided to come back to mess around with it but oh man i must be stuck on something that is so simple but i cant figure it out.

i keep getting the error: cant get tilePosition of undefined. code is below. Thanks in advance! 

var background, playerR, run;
var playState = {
    
    create: function() {
        
        game.add.image(0, 0, 'background');
        
        playerR = game.add.image(200, 400, 'playerR');
        playerR.scale.setTo(1.8, 1.8);
        run = playerR.animations.add('run');
        playerR.animations.play('run', 10, true);
        
        
    },
    
    
    update: function() {
        
     background.tilePosition.x += 2;
        
    }

     
};

 

Link to comment
Share on other sites

4 hours ago, lewster32 said:

You haven't defined background, only initialised it. I assume the first line of the create function needs to be:


background = game.add.image(0, 0, 'background');

 

Thanks for the reply but I have tried that but it still gives me the same error. I'm assuming it has to do with me using states for the first time .  It's gotta be some small error. Any other ideas

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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