evilwizard Posted April 25, 2017 Share Posted April 25, 2017 I looked at the documentation on how to create a sprite https://phaser.io/docs/2.6.2/Phaser.GameObjectFactory.html#sprite It takes in the following parameters x y key frame group It's very easy to add a sprite with just the first three parameters car1 = this.game.add.sprite(800, 400, 'car'); But it fails when I try to add the car to a group car1 = this.game.add.sprite(800, 400, 'car', objects); If I went with the first declaration and then added objects.add(car1) it will then work I need to use the second declaration because my codebase is becoming way too large, and I need fewer lines. Not sure, why this is failing. Maybe an update killed this functionality? Link to comment Share on other sites More sharing options...
samme Posted April 26, 2017 Share Posted April 26, 2017 You need to omit frame (4): car1 = this.game.add.sprite(800, 400, 'car', null, objects); Link to comment Share on other sites More sharing options...
evilwizard Posted April 26, 2017 Author Share Posted April 26, 2017 46 minutes ago, samme said: You need to omit frame (4): car1 = this.game.add.sprite(800, 400, 'car', null, objects); I would like to thank you for your quick response. Indeed, you must pass in something for all of the parameters, even if it's null. I got confused because the documentation said they were optional. Adding null to the frame parameter solves this issue. Once again, thank you. This was very helpful for me Link to comment Share on other sites More sharing options...
Recommended Posts