Do_input is never called despite focus request

I’m working on a multi-screen game and during one of the screens (happens to be endgame screen), I’ve got a collection with 50 objects in it , 48 of which do not acquire focus.

the 49th and 50th objects in endgame.collection are:

bg.go:
a screen-sized sprite
/screens/ending/ending.script

gui.go:
a gui with a box and text that “looks” like a button reading ‘restart’
highscores.gui_script shows the high score

I’ve tried using msg.post(".",“acquire_input_focus”) in the “init” of one or both ending.script and highscores.gui_script, but in both cases relative do_input is NEVER called when I click mouse or whatever.

It’s on_input, test with a new blank script.

If you are using collection proxies for your separate screens - the controller script used to load your proxies should have something like this, in the on_message() function.

	if message_id == hash("proxy_loaded") then
		msg.post(sender, "init")
		msg.post(sender, "enable")
		msg.post(sender, "acquire_input_focus")
        end

It doesn’t really mention this specifically in the manual but it does explain why.

It would be nice to see some global input functions not associated with that

like input.moved input.position … you know, like OTHER engines

You can very easily implement this yourself. A single script in the bootstrap collection could acquire input focus and store this in a shared Lua module.

Defold is in general more restrictive with global structures and things being constantly active and wasting CPU cycles. If you need input in one specific place then you acquire input at that specific place and nowhere else.

3 Likes