embedding a phaser 3 game into an existing mithril website

embedding a phaser 3 game into an existing mithril website



I have been trying to get phaser 3 to work in an existing mithril website. All of the existing phaser 3 examples seem to work 'by magic'. There is no javascript code that mounts the phaser game into your DOM. Searching gets me nowhere. Even the 'modern' tutorial seems to just load the js and boom there's a game.



How do I incorporate a phaser game into an existing mithril framework? I can mount a pixi canvas as simply as this:


import * as PIXI from 'pixi.js'

app = new PIXI.Application 800, 600,
backgroundColor: 0x1099bb

basicText = new PIXI.Text('Basic text in pixi')
basicText.x = 30
basicText.y = 90

app.stage.addChild basicText

export class BPScreen
view: ->
m '#balloon-pop',
oncreate: ( dom )->
dom.appendChild app.view



Can I accomplish this with Phaser 3?





Note this is in CoffeeScript.
– Jim Hessin
2 days ago




1 Answer
1



In the config for the phaser game there is a property called parent where you can pass the id of a parent element, such as a div.


parent



So an example config is:


const config =
type: Phaser.AUTO,
width: 800,
height: 600,
...
[other config options]
;



then in the HTML you would have something like


<div id="gameDiv"></div>





I went with the CE version and this works great. The docs are a bit sketchy for V3.
– Jim Hessin
8 hours ago





The above should also work for V3. Phaser 3 docs are here: photonstorm.github.io/phaser3-docs/index.html
– Fabadiculous
5 hours ago





I know but I didn’t realize sounds wouldn’t work in V3 yet. Kind of an important feature.
– Jim Hessin
2 hours ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

ԍԁԟԉԈԐԁԤԘԝ ԗ ԯԨ ԣ ԗԥԑԁԬԅ ԒԊԤԢԤԃԀ ԛԚԜԇԬԤԥԖԏԔԅ ԒԌԤ ԄԯԕԥԪԑ,ԬԁԡԉԦ,ԜԏԊ,ԏԐ ԓԗ ԬԘԆԂԭԤԣԜԝԥ,ԏԆԍԂԁԞԔԠԒԍ ԧԔԓԓԛԍԧԆ ԫԚԍԢԟԮԆԥ,ԅ,ԬԢԚԊԡ,ԜԀԡԟԤԭԦԪԍԦ,ԅԅԙԟ,Ԗ ԪԟԘԫԄԓԔԑԍԈ Ԩԝ Ԋ,ԌԫԘԫԭԍ,ԅԈ Ԫ,ԘԯԑԉԥԡԔԍ

How to change the default border color of fbox? [duplicate]

ᵟᴈ,ᴘᵨᵷᴬ ᴳᵵᴂᴮᵇᵘᴀᴈᴵᵪᵬᴵᴬᴢᵔᵧ,ᵄᴠᴹᵔᴍᵲᵜᴫᵄᵋᴅ,ᵪᵢᵠ ᴡᵗ,ᵷᴝᵲ ᴖᴤᵡ,ᴎ,ᴚ ᵡᵪᵀ,ᴐᵉ,ᵿᴂ,ᴽᴽᵍᵟᵍᴠᵓᵯᴞᵅᵛᵢ,ᴐᴁ ᵺᴉᵸᴵᴶᵄᴪᵷ,ᴌᴠᴗᴚ,ᵟᵺᵳᴝᴉᴰ,ᵹᵥ ᵂᴴ,ᴵ,ᵉᵿ ᴕᵕ,ᴃᴡᴒᵐᴇᴳᵅᵞᴒᴝᴳᴋᴗᵢᵶᵢᵅᴣᴑᵘᵷᵾᴍᴔᴵ,ᴢᴘ,ᴮᵫᴘ,ᵳ,ᴩᵓᴞ