Jump to content

SpriteBatch undefined


Recommended Posts

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.





Link to comment
Share on other sites

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

  • 2 months later...
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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