arcbox Posted March 18, 2014 Share Posted March 18, 2014 Hey everyone, I'm trying to use SpriteBatch for optimization, and I'm initializing it like this: spriteBatch = new Phaser.SpriteBatch(game, this); But I get the following error on that line: "Uncaught TypeError: undefined is not a function" Am I initializing the spritebatch incorrectly? I would like to avoid game.add if possible. Thanks! Link to comment Share on other sites More sharing options...
rich Posted March 18, 2014 Share Posted March 18, 2014 Why do you not want to use game.add? (or game.make), it handles the references properly for you. But anyway I would guess the problem is that 'this' (in your SpriteBatch constructor) isn't of the required type. What does it equal? It needs to be a Group, or a DisplayObjectContainer at the least. Failing that post the actual line number the error occurs on (assuming its raised within phaser.js and not your own game ) Link to comment Share on other sites More sharing options...
lucbloom Posted May 28, 2014 Share Posted May 28, 2014 I was googling how to add a SpriteBatch via game.add... Guess I'll look into the source :-) It'sgame.add.spriteBatch(parent, name, addToStage) Link to comment Share on other sites More sharing options...
ForgeableSum Posted November 5, 2016 Share Posted November 5, 2016 I think a phaser sprite batch example under the sprites section in examples would be helpful. Link to comment Share on other sites More sharing options...
samme Posted November 6, 2016 Share Posted November 6, 2016 Starfield Batched Link to comment Share on other sites More sharing options...
Recommended Posts