love.js icon indicating copy to clipboard operation
love.js copied to clipboard

love.resize is not called when changing the size of the love.js canvas

Open apicici opened this issue 3 years ago • 6 comments

I just ported my game to love.js (it was a bit tricky because I'm also using fmod), and I noticed that love.resize is not called when the love.js canvas is resized (including when going to fullscreen mode). I have t.window.resizable = true in conf.lua and I tried on chromium and firefox on Linux.

Is this the expected behaviour? This seems to be a similar issue to #33 (I also get blurry fullscreen because love.resize is not called), but my understanding by reading the comments there is that setting t.window.resizable = true should lead to love.resize being called when changing the canvas size.

apicici avatar Apr 15 '22 14:04 apicici

This should have been solved but see this https://github.com/Davidobot/love.js/issues/16#issuecomment-818620056

Davidobot avatar Apr 15 '22 14:04 Davidobot

I saw that when I was searching earlier, but I'm not sure how that can help. All of the things listed in that comment are already implemented in the index.html file, but the love.resize callback is never called (not even once). Is there a way to trigger love.resize from javascript?

apicici avatar Apr 15 '22 19:04 apicici

To call lua (e.g. love.resize) from JS and vice versa, check out the Love.js API player, referenced in #26

https://github.com/MrcSnm/Love.js-Api-Player

alexjgriffith avatar Apr 21 '22 02:04 alexjgriffith

To call lua (e.g. love.resize) from JS and vice versa, check out the Love.js API player, referenced in #26

https://github.com/MrcSnm/Love.js-Api-Player

I've been using that to make fmod work by calling JavaScript from lua, but it's not clear to me by reading the instructions how to call lua functions from JavaScript.

apicici avatar Apr 21 '22 11:04 apicici

You can use JS.newRequest from within love to call a JavaScript function polling the size of the canvas and call love.resize when there is a change. Make sure you call JS.retrieveData in the update loop. Note, you will also have to run globalizeFS.js on the love.js file to get FS working in this fork. There are instructions in the README.

This is a bit of a hack. We could see about implementing stdin stdout for the module, which would let you interact with a repl.

alexjgriffith avatar Apr 21 '22 16:04 alexjgriffith

I'll try that, thanks!

apicici avatar Apr 21 '22 16:04 apicici