Question

I want to use multiple new Phaser.Game instances with Phaser.io but everything when I create a second Phaser.Game object I get the following error WebGL: INVALID_OPERATION: uniform2f: location not for current program

This is the HTML code I user

<div id="player1Holder"></div>
<div id="player2Holder"></div>

This is the JavaScript code I user

new Phaser.Game(700, 850, Phaser.AUTO, 'player1Holder');
new Phaser.Game(700, 850, Phaser.AUTO, 'player2Holder');
Was it helpful?

Solution

You can't currently embed more than one Phaser game in a single page unless:

  • The games use the Canvas Renderer only, OR
  • Each game is in its own iframe.

This is because Phaser uses Pixi.js for rendering, and Pixi doesn't currently support multiple instances of its WebGL renderer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top