mrxj88 Posted August 7, 2017 Share Posted August 7, 2017 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 More sharing options...
Braxen Posted August 7, 2017 Share Posted August 7, 2017 you're not defining the variable 'background' anywhere Link to comment Share on other sites More sharing options...
lewster32 Posted August 7, 2017 Share Posted August 7, 2017 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'); Link to comment Share on other sites More sharing options...
mrxj88 Posted August 7, 2017 Author Share Posted August 7, 2017 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 More sharing options...
mrxj88 Posted August 8, 2017 Author Share Posted August 8, 2017 I figured it out. I was supposed to add it as a tileSprite instead of add.image to have it to work. just figured i put that out there if anybody else had the same problem. Link to comment Share on other sites More sharing options...
Recommended Posts