MaxAg Posted June 13, 2018 Share Posted June 13, 2018 Hi, I'm trying to change texture of a sprite but it's not working.... player = this.physics.add.sprite(200, 100, 'dude'); player.loadTexture('dudeGun', 0, false); but i have this error message : player.loadTexture is not a function Apparently this method is only for this.add.sprite, not for physics... do we have any equivalent method when we use physics? Thanks! Link to comment Share on other sites More sharing options...
rich Posted June 13, 2018 Share Posted June 13, 2018 It’s not a valid function at all, for anything. Use setTexture instead. Link to comment Share on other sites More sharing options...
MaxAg Posted June 13, 2018 Author Share Posted June 13, 2018 thanks for your answer but when I use : player.setTexture('dudeGun'); It's not modifying the texture. No error message niether... Link to comment Share on other sites More sharing options...
rich Posted June 14, 2018 Share Posted June 14, 2018 It's likely not a valid texture key then. With no code or assets to see you'll have to figure this one out yourself, but that's the right method to call in Phaser 3. Link to comment Share on other sites More sharing options...
Recommended Posts