Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phaser.io multiple phaser.game instances

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');
like image 667
Jürgen Brandstetter Avatar asked Apr 17 '14 00:04

Jürgen Brandstetter


1 Answers

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.

like image 131
PhotonStorm Avatar answered Nov 01 '22 04:11

PhotonStorm