1 - the level starts, so 10 GO (type-A) are puted in world. each one with the input_focus actived.
2 - when clicked, each GO put anothers 2 (1 type-A and 1 type-B ) GO in world, with the input_focus too.
3 - so, after some clicks i receive a warn:
obs: only the GO type A build a new GO’s
WARNING:GAMEOBJECT: Input focus could not be acquired since the buffer is full (16).
I know that 16 it is the max value allowed, but is there some way to solve this situation?
You can consolidate the input handling in a Lua module. For instance each type-A object can have a table with listeners, each type-B object will define a listener function and you can put all these functions into the mentioned table. Then in the input handler you can iterate over that table and pass input events to the type-B objects.
You can also organise it through a heavy use of the messaging system.
When you and @sergey.lerg says “consolidade input” you are speaking about something like this sample?
function init(self)
msg.post(".", "acquire_input_focus")
math.randomseed(os.time())
self.things = {}
for i=1,5 do
local id = factory.create("#factory", vmath.vector3(math.random(40,996), math.random(40,600), 0))
table.insert(self.things, id)
end
end
function on_input(self, action_id, action)
if action.released then
for i=1,#self.things do
local id = self.things[i]
local pos = go.get_position(id)
if action.x > (pos.x - 30) and action.x < (pos.x + 30) and action.y > (pos.y - 35) and action.y < (pos.y + 35) then
go.delete(id)
table.remove(self.things, i)
break
end
end
if #self.things == 0 then
msg.post("controller:/controller", "show_menu")
end
end
end
this code was extracted from your “Menu and game” public samples
Yes, exactly. In that example I spawn 5 game objects and when clicking on a game object it is deleted. When all game objects are deleted the “game” ends and return to the menu.
The above example can be solved in two ways:
Let each game object have a script that acquires input focus. Let each script detect if a touch/click is near/on the game object and in that case delete it and send a message to a game controller of some kind that can keep track of when all game objects are deleted.
Have a single game controller script that acquires input focus. Let that script detect if a touch/click is near/on any of the game objects and in that case delete it.
Consolidating the input would in this case mean #2.