dluz Posted November 28, 2014 Share Posted November 28, 2014 Hello everybody! First congratulations on this forum! He has helped me a lot with phaserJs. I work with developing educational materials to Moodle and am trying to use the phaser in my applications. I would like to know how to write in a specific canvas element using the PhaserJS. That is, I can write in a predefined Canvas element? Link to comment Share on other sites More sharing options...
eguneys Posted November 28, 2014 Share Posted November 28, 2014 Wow that's not possible I think, why do you want to use an existing canvas, maybe Phaser isn't the best option for you. dluz 1 Link to comment Share on other sites More sharing options...
dluz Posted November 28, 2014 Author Share Posted November 28, 2014 I really did not want to use the Canvas ... but in Moodle, which is the environment we work here, provides only a html editor field, when I call the phaser in this environment, it appears within the page and not the specific html space ... Since the Canvas, moodle easily recognize. Thanks for the reply. Link to comment Share on other sites More sharing options...
Mickawesomesque Posted November 28, 2014 Share Posted November 28, 2014 Hi, When you use Phaser.Game to create your game, you can pass a pre-existing canvas element in the arguments:Game(width, height, renderer, parent, state, transparent, antialias, physicsConfig)Where "parent" should be the id of your canvas. More details here: http://docs.phaser.io/Phaser.Game.htmlHope that was what you were looking for! dluz 1 Link to comment Share on other sites More sharing options...
eguneys Posted November 28, 2014 Share Posted November 28, 2014 I don't understand what's wrong by Phaser creating a custom canvas for you. You call Phaser.Game giving it a dom element id, and it places the canvas there. So you add this to your html<div id="game-area"></div>and call Phaser.Gamenew Phaser.Game(640, 480, Phaser.AUTO, 'game-area');This will create a canvas within the '#game-area' So are you saying this is not possible using moodle, If not explain your problem more please. dluz 1 Link to comment Share on other sites More sharing options...
dluz Posted November 28, 2014 Author Share Posted November 28, 2014 It was just that I needed eguneys !! Thank you very much! Helped me a lot. "I was racking my brains here". Sorry, I'm still learning how to use the phaser. Now I can embedd my Phaser content within Moodle. Link to comment Share on other sites More sharing options...
Recommended Posts