Hello,
I am creating each letterbox as in the examples below through a factory, via factory.create.
It happens that sometimes (not always), objects are created in the wrong positions.
I activated the space key to redraw the objects with exactly the same parameters and positions and the second time this is done everything is in the correct position.
Example drawn in the wrong positions:
After deleting and redrawing with very same parameters:
Code to create each letterbox:
local function create_letterbox(letter, pos, scale)
local component = "/leterbox_factory#letterbg_factory"
local c = factory.create(component, pos)
go.set_scale(scale, c)
-- go.set_position(pos, c) -- tried this with same result
msg.post(c, hashes.SET_LETTER, { letter = letter })
return c
end
function draw_board()
for _, word_map in pairs(board_def.words_map) do
for _, letter_map in ipairs(word_map) do
local obj = letter_map.obj
if board_def.objects[obj] == "" then
local pos = vmath.vector3(sizes.left, sizes.top, 0)
local letterobj = create_letterbox(letter_map.letter, pos, sizes.letterbox_scale)
letter_map.pos = {x = pos.x, y = pos.y}
board_def.objects[obj] = letterobj;
end
end
end
code do clear all letterbox
local function clear_board()
print("clear_board")
for obj, object in pairs(board_def.objects) do
go.delete(object)
board_def.objects[obj] = ""
end
end