bali33 Posted January 20, 2015 Share Posted January 20, 2015 Hello, I'm trying to draw a group into a BitmapData it fails - Here the code flloawed byt the console output :var bmd = game.add.bitmapData(game.width, game.height);bmd.addToWorld();bmd.drawGroup(root);Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.phaser.js:36430 c.BitmapData.copyphaser.js:22231 c.Group.iteratephaser.js:22016 c.Group.forEachExistsphaser.js:36500 c.BitmapData.drawGroupAny idea why it failed ? Thank you Link to comment Share on other sites More sharing options...
rich Posted January 20, 2015 Share Posted January 20, 2015 Simple question - what is 'root' ? Where do you define it? Link to comment Share on other sites More sharing options...
bali33 Posted January 20, 2015 Author Share Posted January 20, 2015 Hi, Root is a Group - The variable is declare at the top of my script - the game variable is declare at the same place.var game ; var root;window.onload = function() { game = new Phaser.Game(800, 800, Phaser.AUTO, 'francetv-game', { init:init, preload: preload, create: create }); function init(){ console.log("Init game"); } function preload(){ game.load.atlas('animations', 'assets/animations.png', 'assets/animations.json'); game.load.atlasXML('levelAssets', 'assets/levelAssets.png', 'assets/levelAssets.xml'); } function create(){ game.stage.backgroundColor = 0xFF0000; //Detect local var locale = document.documentElement.lang; if(locale != "fr" && locale != "de") locale = "fr"; //Load dico XML var dicoXML = loadXMLString("assets/dico_" + locale + ".xml"); //Create Dico class instance var dico = new Dico(); dico.parseXML(dicoXML); //Root groop root = game.add.group(); //Scene config var conf = loadXMLString("assets/test.xml"); //Create a new Scene var scene = new Scene(game,dico); //Init the scene with the config file scene.buildFromXml(conf); //Add the Scene into the root group root.addChild(scene); //Retrieve Scene child by thei id var sceneRoot = scene.getChildByName("root"); var btn = scene.getChildByName("btn"); btn.onInputUp.add(up, this); }};function up() { var bmd = game.add.bitmapData(game.width, game.height);bmd.addToWorld();bmd.drawGroup(root);} Link to comment Share on other sites More sharing options...
rich Posted January 20, 2015 Share Posted January 20, 2015 Two things: 1) It should be root.add - not root.addChild. 2) What is 'scene' ? Is it another Group? drawGroup doesn't iterate, it only draws Sprite children, nothing else. Link to comment Share on other sites More sharing options...
bali33 Posted January 20, 2015 Author Share Posted January 20, 2015 1) ok - what's the difference ? 2) Scene extends Group Thank you Link to comment Share on other sites More sharing options...
rich Posted January 20, 2015 Share Posted January 20, 2015 1) addChild is a Pixi level function, doesn't apply the correct z-index value and shouldn't be used in Group. 2) That's the problem then - drawGroup only draws Groups with sprites as children. root doesn't contain sprites. Link to comment Share on other sites More sharing options...
Recommended Posts