San4er Posted September 18, 2014 Share Posted September 18, 2014 I can't make it, help please I'm using Phaser 2.1.1. var bmd=game.make.bitmapData(100,100);bmd.draw('background',0,0);var sLeaf=game.make.image(0,0,'leaf2');bmd.draw(sLeaf,0,0);//works finevar sText=game.make.bitmapText(0,0,'myFont','blah blah',30);bmd.draw(sText,0,0);//doesn't workbmd.update();game.add.image(0,0,bmd);I get an error "Argument 1 of CanvasRenderingContext2D.drawImage could not be converted to any of: HTMLImageElement, HTMLCanvasElement, HTMLVideoElement. phaser.js:31756" when I try this.I also tried bmd.load, bmd.copy and bmd.copyRect. Nothing works.It seems like bitmapData.load supports all kind of sources(Phaser.Sprite| Phaser.Image| Phaser.Text | Phaser.BitmapData | HTMLImage |HTMLCanvasElement | string) but not a BitmapText:http://docs.phaser.io/Phaser.BitmapData.html#loadIs there any solution to draw bitmapText on the bitmapData? Link to comment Share on other sites More sharing options...
FSDaniel Posted October 30, 2014 Share Posted October 30, 2014 The thread might be a little old, but was the only thing that popped up when I googled the problem. This is how it worked for me.var bitmapData = new Phaser.BitmapData(game, null, 1920, 1080);var bitmapText = new Phaser.BitmapText(game, 0, 0, 'font', 'Hello BitmapData', 48);bitmapText.updateText();// Build a canvas-backed Sprite/RenderTexture for the BitmapData and cache itvar canvasRenderer = new PIXI.CanvasRenderer(bitmapText.width, bitmapText.height);var renderTexture = new PIXI.RenderTexture(bitmapText.width, bitmapText.height, canvasRenderer);bitmapText._cachedSprite = new Phaser.Sprite(game, 0, 0, renderTexture);bitmapText._cachedSprite.worldTransform = bitmapText.worldTransform;bitmapText.cacheAsBitmap = true;// Draw the cached SpritebitmapData.draw(bitmapText._cachedSprite, x, y); San4er 1 Link to comment Share on other sites More sharing options...
San4er Posted October 30, 2014 Author Share Posted October 30, 2014 Thanx anyway, I'm sure it would be helpful for someone Link to comment Share on other sites More sharing options...
jdnichollsc Posted March 2, 2015 Share Posted March 2, 2015 Mi example: http://codepen.io/jdnichollsc/pen/dPKLgK Regards, Nicholls Link to comment Share on other sites More sharing options...
Recommended Posts