Jump to content

Phaser canvas context 2d?


xronn
 Share

Recommended Posts

Hi,

 

I want to write my own javascript as part of my game, so I'm loading another js file such as menu.js and then inside that file I want to draw my own image to the canvas so I write the following code;

 

var canvas = document.getElementById('canvas');var ctx = canvas.getContext('2d');var backpackBtn = new Image();	backpackBtn.onload = function() {	ctx.drawImage(backpackBtn, 50, 630);	};	backpackBtn.src = '././sprites/ui/item_btn.png';

But phaser uses the canvas in webgl mode, and a canvas can't have both webgl and 2d, so can i make phaser use 2d so I can write my own javascript along side? 

Link to comment
Share on other sites

Yeah I suppose, but how can I call them from an external js file if I want to have say a userInterface.js I'll preload the images then in my game create I'll draw them but then how can I write my own js inside my userInterface.js file. I wouldn't have anyway of calling the ui sprites I've drawn on in the create?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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